mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
nokaslr, thanks to @dakami at close #12
This commit is contained in:
@@ -34,7 +34,10 @@ which counts to infinity to stdout, and then in GDB:
|
|||||||
|
|
||||||
And you now control the counting from GDB.
|
And you now control the counting from GDB.
|
||||||
|
|
||||||
See also: <http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu>
|
See also:
|
||||||
|
|
||||||
|
- <http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu/33203642#33203642>
|
||||||
|
- <http://stackoverflow.com/questions/4943857/linux-kernel-live-debugging-how-its-done-and-what-tools-are-used/42316607#42316607>
|
||||||
|
|
||||||
`O=0` is an impossible dream, `O=2` being the default: <https://stackoverflow.com/questions/29151235/how-to-de-optimize-the-linux-kernel-to-and-compile-it-with-o0> So get ready for some weird jumps, and `<value optimized out>` fun. Why, Linux, why.
|
`O=0` is an impossible dream, `O=2` being the default: <https://stackoverflow.com/questions/29151235/how-to-de-optimize-the-linux-kernel-to-and-compile-it-with-o0> So get ready for some weird jumps, and `<value optimized out>` fun. Why, Linux, why.
|
||||||
|
|
||||||
@@ -73,6 +76,8 @@ Just don't forget to remove your breakpoints after `rmmod`, or they will point t
|
|||||||
|
|
||||||
TODO: why does `break work_func` for `insmod kthread.ko` not break the first time I `insmod`, but breaks the second time?
|
TODO: why does `break work_func` for `insmod kthread.ko` not break the first time I `insmod`, but breaks the second time?
|
||||||
|
|
||||||
|
See also: <http://stackoverflow.com/questions/28607538/how-to-debug-linux-kernel-modules-with-qemu/44095831#44095831>
|
||||||
|
|
||||||
### Bypassing lx-symbols
|
### Bypassing lx-symbols
|
||||||
|
|
||||||
Useless, but a good way to show how hardcore you are. From inside QEMU:
|
Useless, but a good way to show how hardcore you are. From inside QEMU:
|
||||||
|
|||||||
4
run
4
run
@@ -10,7 +10,9 @@ kgdb=false
|
|||||||
nographic=false
|
nographic=false
|
||||||
# norandmaps: Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space.
|
# norandmaps: Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space.
|
||||||
# printk.time=y: log in format: "[time ] msg" for all printk messages.
|
# printk.time=y: log in format: "[time ] msg" for all printk messages.
|
||||||
extra_append='norandmaps printk.devkmsg=on printk.time=y'
|
# nokaslr: https://unix.stackexchange.com/questions/397939/turning-off-kaslr-to-debug-linux-kernel-using-qemu-and-gdb
|
||||||
|
# Turned on by default since v4.12
|
||||||
|
extra_append='nokaslr norandmaps printk.devkmsg=on printk.time=y'
|
||||||
extra_flags=''
|
extra_flags=''
|
||||||
while getopts a:de:knqt:x OPT; do
|
while getopts a:de:knqt:x OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
|
|||||||
41
rungdb
41
rungdb
@@ -42,32 +42,29 @@ if "$kgdb"; then
|
|||||||
else
|
else
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
'x86_64')
|
'x86_64')
|
||||||
# http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu/33203642#33203642
|
|
||||||
# http://stackoverflow.com/questions/4943857/linux-kernel-live-debugging-how-its-done-and-what-tools-are-used/42316607#42316607
|
|
||||||
# http://stackoverflow.com/questions/28607538/how-to-debug-linux-kernel-modules-with-qemu/44095831#44095831
|
|
||||||
cmd="$gdb \
|
cmd="$gdb \
|
||||||
-q \
|
-q \
|
||||||
-ex 'add-auto-load-safe-path $(pwd)' \
|
-ex 'add-auto-load-safe-path $(pwd)' \
|
||||||
-ex 'file vmlinux' \
|
-ex 'file vmlinux' \
|
||||||
-ex 'set arch i386:x86-64:intel' \
|
-ex 'set arch i386:x86-64:intel' \
|
||||||
-ex 'target remote localhost:1234' \
|
-ex 'target remote localhost:1234' \
|
||||||
$brk \
|
$brk \
|
||||||
-ex 'continue' \
|
-ex 'continue' \
|
||||||
-ex 'disconnect' \
|
-ex 'disconnect' \
|
||||||
-ex 'set arch i386:x86-64' \
|
-ex 'set arch i386:x86-64' \
|
||||||
-ex 'target remote localhost:1234' \
|
-ex 'target remote localhost:1234' \
|
||||||
-ex 'lx-symbols ../kernel_module-1.0/' \
|
-ex 'lx-symbols ../kernel_module-1.0/' \
|
||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
'arm'|'aarch64'|'mips64')
|
'arm'|'aarch64'|'mips64')
|
||||||
cmd="$gdb \
|
cmd="$gdb \
|
||||||
-q \
|
-q \
|
||||||
-ex 'add-auto-load-safe-path $(pwd)' \
|
-ex 'add-auto-load-safe-path $(pwd)' \
|
||||||
-ex 'file vmlinux' \
|
-ex 'file vmlinux' \
|
||||||
-ex 'target remote localhost:1234' \
|
-ex 'target remote localhost:1234' \
|
||||||
-ex 'lx-symbols ../kernel_module-1.0/' \
|
-ex 'lx-symbols ../kernel_module-1.0/' \
|
||||||
$brk \
|
$brk \
|
||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user