Achieving memory safety is hard. Code is written by humans, and humans are bound to make mistakes. Tack on pointer arithmetic and strict aliasing and the situation only becomes more complex. ZDNet recently posted an article stating that 70 percent of all (Microsoft) security bugs are memory safety issues, and I would guess that this statistic is not specific to Microsoft. In LLVM 3.1 and in GCC 4.8, the compilers introduced the -fsanitize=address
option and the asan
libraries for user-space applications to be built with the Address Sanitizer.
There are many great tools that are useful for debugging the Linux kernel, including good old-fashioned printk
, ftrace, and kgdb
. In this post we’ll be exploring how to use the kernel debugger (kgdb
) to debug a QEMU VM, although some of the techniques below may be applied to debugging via hardware interfaces like JTAG. Using gdb
as a front-end for the kernel debugger allows us to debug the kernel in the familiar and powerful debugging interface of gdb
.