I'm trying to debug linux kernel using qemu and gdb. The problem is that gdb won't stop at breakpoint. I've searched about it and found that turning kASLR off may help, because kASLR confuses gdb.

-- Install that kernel on the guest.

+- Install that kernel on the guest, turn off KASLR by adding "nokaslr" to the kernel command line .

now I don't know what it means to add nokaslr to command line and the way to do that. Any idea?

  • I added "nokaslr" as it says in the link and the kernel boots normally. Therefore, it must be the right way. Thanks. – Winston Oct 13 '17 at 15:38

Kernel boot parameters can be set temporarily per boot or always via some configuration file; how this is done depends on the bootloader which for current versions of Ubuntu is grub2;

$ grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub
$ sudo perl -i -pe 'm/quiet/ and s//quiet nokaslr/' /etc/default/grub
$ grep quiet /etc/default/grub
$ sudo update-grub

and then reboot; confirm at the grub menu that the parameters appear as expected.


qemu-system-x86_64 -append nokaslr

The nokasrl Linux command line parameter disables KASRL.

This has been needed since v4.12, when KASLR was turned on by default.

Here is a highly automated Buildroot example that uses it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.