Add config option to start qemu for kernel gdb debug.
Specify the nokaslr kernel parameter to disable kernel randomization, that is, cause the kernel to be loaded at its standard location.
Set norandmaps so that we do not use address space randomization.
Signed-off-by: Tudor Ambarus tudor.ambarus@linaro.org --- syzkaller-start | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/syzkaller-start b/syzkaller-start index 55b8a04..305d09d 100644 --- a/syzkaller-start +++ b/syzkaller-start @@ -10,10 +10,12 @@ occurence=1
function usage() { - echo "Usage: $(basename $0) [<URL or ID> <report occurence>] [--again]" + echo "Usage: $(basename $0) [<URL or ID> <report occurence>] [--again] [--gdb]" echo echo -e "\t--again" echo -e "\t\tUse the current kernel commit and run qemu directly." + echo -e "\t--gdb" + echo -e "\t\tdebug with gdb" exit 1 }
@@ -37,6 +39,9 @@ while [ $# -gt 0 ]; do --again|-a) AGAIN=true ;; + --gdb) + GDB="-s -S" + ;; --norepro|-n) NOREPRO=true ;; @@ -60,6 +65,10 @@ if [ "${url}" == "" ]; then usage fi
+if [ -n "${GDB}" ]; then + KERNEL_PARAMS="nokaslr norandmaps" +fi + reset # Required on subsequent runs, since QEMU borks the terminal
print_blue "Starting SyzKaller Repro" @@ -292,6 +301,10 @@ oldconfig="ccache make KBUILD_OUTPUT=${BUILDDIR} CC=${COMPILER} oldconfig" echo "${oldconfig}" yes "" | ${oldconfig}
+if [ -n "${GDB}" ]; then + scripts/config --file ${BUILDDIR}/.config --enable GDB_SCRIPTS +fi + if grep -q KASAN_STACK_ENABLE lib/Kconfig.kasan; then scripts/config --file ${BUILDDIR}/.config --enable KASAN_STACK_ENABLE scripts/config --file ${BUILDDIR}/.config --set-val KASAN_STACK 1 @@ -314,7 +327,7 @@ if [[ -z "${AGAIN}" && -z "${NOREPRO}" ]]; then read fi
-qemu-system-x86_64 -smp 8 -m 16G -enable-kvm -cpu host -no-reboot \ +qemu-system-x86_64 -smp 8 -m 16G -enable-kvm -cpu host -no-reboot ${GDB} \ -kernel ${BUILDDIR}/arch/x86/boot/bzImage -nographic \ -net user,host=10.0.2.10,hostfwd=tcp::10022-:22 \ -net nic,model=virtio-net-pci \ @@ -323,4 +336,4 @@ qemu-system-x86_64 -smp 8 -m 16G -enable-kvm -cpu host -no-reboot -drive file=${IMAGEDIR}/${IMAGE},format=raw,if=none,id=d0 \ -chardev stdio,id=char0,mux=on,logfile=serial.out,signal=off \ -serial chardev:char0 -mon chardev=char0 \ - -append "root=/dev/sda1 rw console=ttyAMA0 panic_on_warn=0" + -append "root=/dev/sda1 ${KERNEL_PARAMS} rw console=ttyAMA0 panic_on_warn=0"