summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--syzkaller-start117
1 files changed, 83 insertions, 34 deletions
diff --git a/syzkaller-start b/syzkaller-start
index 49a00d0..6e784f6 100644
--- a/syzkaller-start
+++ b/syzkaller-start
@@ -24,6 +24,54 @@ print_red()
echo -e "\e[01;31m$@ \e[0m"
}
+build_local()
+{
+ COMPILERDIR=${SYZKALLERDIR}/compilers/${COMPILER_VERSION}
+ mkdir -p ${COMPILERDIR}
+
+ pushd ${COMPILERDIR} > /dev/null
+ if echo ${COMPILER_VERSION} | grep -q clang; then
+ # Parent directory in the Clang packages is already named correctly
+ cd ..
+ rmdir --ignore-fail-on-non-empty ${COMPILER_VERSION}
+
+ COMPILER=${COMPILERDIR}/bin/clang
+ else
+ if [ -z ${COMPILER_BIN_PATH} ]; then
+ COMPILER=${COMPILERDIR}/gcc/bin/gcc
+ else
+ COMPILER=${COMPILERDIR}/${COMPILER_BIN_PATH}
+ fi
+ fi
+
+ if [ ! -f $(basename ${COMPILER_URL}) ]; then
+ print_blue "\nDownloading ${COMPILER_VERSION}:\n\n\t${COMPILER_URL}"
+ curl -C - -sLO --show-error ${COMPILER_URL}
+
+ if echo ${COMPILER_URL} | grep -q "gz$"; then
+ tar -xzf ${COMPILER_VERSION}.tar.gz
+ else
+ tar -xJf ${COMPILER_VERSION}.tar.xz
+ fi
+ else
+ print_blue "\nUsing ${COMPILER_VERSION}"
+ fi
+
+ popd > /dev/null # ${COMPILERDIR}
+
+ compile="ccache make -j$(nproc) KBUILD_OUTPUT=${BUILDDIR} CC=${COMPILER}"
+}
+
+build_in_docker()
+{
+ docker images | grep -q "gcr.io/syzkaller"
+ if [ 0 -ne $? ] ; then
+ docker pull ${COMPILER_URL}
+ fi
+ LINUX_SRC_DIR=`basename $PWD`
+ compile="docker run --user $(id -u ${USER}):$(id -g ${USER}) --volume "$PWD/../:/syzkaller/pwd" --workdir /syzkaller/pwd gcr.io/syzkaller/env make -j$(nproc) -C ${LINUX_SRC_DIR} O=${BUILDDIR_RELATIVE} CC=${COMPILER_VERSION}"
+}
+
if [ ! -d .git ] || [ ! -f MAINTAINERS ]; then
print_red "Not in a kernel directory"
exit 1
@@ -64,7 +112,8 @@ print_blue "Starting SyzKaller Repro"
baseurl="https://syzkaller.appspot.com"
bugid=$(echo ${url} | sed "s!.*=!!")
-BUILDDIR=${PWD}/../builds/build-syzkaller
+BUILDDIR_RELATIVE=../builds/build-syzkaller
+BUILDDIR=${PWD}/${BUILDDIR_RELATIVE}
mkdir -p ${BUILDDIR}
SYZKALLERDIR=${PWD}/../builds/syzkaller
mkdir -p ${SYZKALLERDIR}
@@ -132,7 +181,7 @@ COMPILER_CHOICE_FILE=${sandbox}/compiler_choice
touch ${COMPILER_CHOICE_FILE}
COMPILER_CHOICE=$(cat ${COMPILER_CHOICE_FILE})
-while [[ ${COMPILER_CHOICE} -lt 1 || ${COMPILER_CHOICE} -gt 11 ]]; do
+while [[ ${COMPILER_CHOICE} -lt 1 || ${COMPILER_CHOICE} -gt 13 ]]; do
print_blue "\nWhich compiler version would you like (default: Clang 11.0.1)?\n"
print_blue "> HINT: You can probably find this at: ${statusurl}\n"
echo -e "\t1. [gcc 7.1.1 20170620]"
@@ -145,6 +194,9 @@ while [[ ${COMPILER_CHOICE} -lt 1 || ${COMPILER_CHOICE} -gt 11 ]]; do
echo -e "\t8. [clang 8.0.0 (trunk 343298)]"
echo -e "\t9. [clang 10.0.0 (c2443155)]"
echo -e "\t10. [clang 11.0.1 (llvm-11.0.1)]"
+ echo -e "\t11. [gcc-10.2.1 (docker: gcr.io/syzkaller/env)]"
+ echo -e "\t12. [gcc-10.2.0]"
+ echo -e "\t13. [clang 13.0.1 (docker: gcr.io/syzkaller/env)]"
echo -n "> "
read COMPILER_CHOICE
@@ -176,6 +228,7 @@ while [ "${COMPILER_VERSION}" == "" ]; do
5)
COMPILER_URL="https://storage.googleapis.com/syzkaller/gcc-10.1.0-syz.tar.xz"
COMPILER_VERSION="gcc-10.1.0-syz"
+ COMPILER_BIN_PATH="gcc-10/bin/gcc"
;;
6)
COMPILER_URL="https://storage.googleapis.com/syzkaller/clang-kmsan-329060.tar.gz"
@@ -205,6 +258,21 @@ while [ "${COMPILER_VERSION}" == "" ]; do
COMPILER_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.1/clang+llvm-11.0.1-x86_64-linux-gnu-ubuntu-20.10.tar.xz"
COMPILER_VERSION="clang+llvm-11.0.1-x86_64-linux-gnu-ubuntu-20.10"
;;
+ 11)
+ COMPILER_DOCKER="y"
+ COMPILER_URL="gcr.io/syzkaller/env"
+ COMPILER_VERSION="gcc-10"
+ ;;
+ 12)
+ COMPILER_URL="https://storage.googleapis.com/syzkaller/gcc-10.2.0.tar.gz"
+ COMPILER_VERSION="gcc-10.2.0"
+ COMPILER_BIN_PATH="bin/gcc"
+ ;;
+ 13)
+ COMPILER_DOCKER="y"
+ COMPILER_URL="gcr.io/syzkaller/env"
+ COMPILER_VERSION="clang-13"
+ ;;
*)
print_red "ERROR: Something went wrong"
exit 1
@@ -212,34 +280,6 @@ while [ "${COMPILER_VERSION}" == "" ]; do
esac
done
-COMPILERDIR=${SYZKALLERDIR}/compilers/${COMPILER_VERSION}
-mkdir -p ${COMPILERDIR}
-
-pushd ${COMPILERDIR} > /dev/null
-if echo ${COMPILER_VERSION} | grep -q clang; then
- # Parent directory in the Clang packages is already named correctly
- cd ..
- rmdir --ignore-fail-on-non-empty ${COMPILER_VERSION}
-
- COMPILER=${COMPILERDIR}/bin/clang
-else
- COMPILER=${COMPILERDIR}/gcc/bin/gcc
-fi
-
-if [ ! -f $(basename ${COMPILER_URL}) ]; then
- print_blue "\nDownloading ${COMPILER_VERSION}:\n\n\t${COMPILER_URL}"
- curl -C - -sLO --show-error ${COMPILER_URL}
-
- if echo ${COMPILER_URL} | grep -q "gz$"; then
- tar -xzf ${COMPILER_VERSION}.tar.gz
- else
- tar -xJf ${COMPILER_VERSION}.tar.xz
- fi
-else
- print_blue "\nUsing ${COMPILER_VERSION}"
-fi
-
-popd > /dev/null # ${COMPILERDIR}
IMAGEDIR=${SYZKALLERDIR}/images
mkdir -p ${IMAGEDIR}
@@ -296,19 +336,28 @@ if grep -q KASAN_STACK_ENABLE lib/Kconfig.kasan; then
scripts/config --file ${BUILDDIR}/.config --enable INIT_STACK_ALL_ZERO
fi
-compile="ccache make -j$(nproc) KBUILD_OUTPUT=${BUILDDIR} CC=${COMPILER}"
+if [ "${COMPILER_DOCKER}" = 'y' ]; then
+ build_in_docker
+else
+ build_local
+fi
+
+echo "${sandbox}/compiler_choice :"
echo "${compile}"
yes "" | ${compile}
+COMMIT=`git log --oneline | head -n 1 | awk '{print $1;}'`
SSHARGS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes"
if [[ -z "${AGAIN}" && -z "${NOREPRO}" ]]; then
+ tput bel;sleep 1;tput bel;
print_blue "Copy these command(s), then hit return:\n"
echo -n "scp -P 10022 ${SSHARGS} ${reproexe} root@localhost:/root/ && "
- echo "ssh -p 10022 ${SSHARGS} root@localhost \"while true; do ./repro; done\""
+ echo "ssh -p 10022 ${SSHARGS} root@localhost \"echo \"\n\nTesting bug: ${bugid}\n\n\" > /dev/ttyS0;chmod uo+x ./repro; while true; do ./repro; done\""
read
fi
+TIME_TAG=`date +%Y%m%d_%H-%M-%S%z`
qemu-system-x86_64 -smp 8 -m 16G -enable-kvm -cpu host -no-reboot \
-kernel ${BUILDDIR}/arch/x86/boot/bzImage -nographic \
-net user,host=10.0.2.10,hostfwd=tcp::10022-:22 \
@@ -316,6 +365,6 @@ qemu-system-x86_64 -smp 8 -m 16G -enable-kvm -cpu host -no-reboot
-device virtio-scsi-pci,id=scsi \
-device scsi-hd,bus=scsi.0,drive=d0 \
-drive file=${IMAGEDIR}/${IMAGE},format=raw,if=none,id=d0 \
- -chardev stdio,id=char0,mux=on,logfile=serial.out,signal=off \
+ -chardev stdio,id=char0,mux=on,logfile=serial.out.$bugid-$TIME_TAG-$COMMIT,signal=off \
-serial chardev:char0 -mon chardev=char0 \
- -append "root=/dev/sda1 rw console=ttyAMA0 panic_on_warn=0"
+ -append "root=/dev/sda1 rw console=ttyAMA0 panic_on_warn=0 kasan.fault=panic"