Skip to content

Commit 839271e

Browse files
committed
rand_check: move docs to readme, create norandmaps section
1 parent 7b8811e commit 839271e

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed

README.adoc

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,23 @@ core_param(panic, panic_timeout, int, 0644);
10211021
*/
10221022
....
10231023

1024+
==== norandmaps
1025+
1026+
Disable userland address space randomization. Test it out by running <<rand_check-out>> twice:
1027+
1028+
....
1029+
./run -F '/rand_check.out;/poweroff.out'
1030+
./run -F '/rand_check.out;/poweroff.out'
1031+
....
1032+
1033+
If we remove it from our link:run[] script by hacking it up, the addresses shown by `rand_check.out` vary across boots.
1034+
1035+
Equivalent to:
1036+
1037+
....
1038+
echo 0 > /proc/sys/kernel/randomize_va_space
1039+
....
1040+
10241041
=== insmod alternatives
10251042

10261043
==== modprobe
@@ -6509,6 +6526,10 @@ Unfortunately it is not working in the current QEMU: https://stackoverflow.com/q
65096526

65106527
Patches were merged in post v2.12.0-rc2 but it crashed for me and I opened a minimized bug report: https://bugs.launchpad.net/qemu/+bug/1762179
65116528

6529+
We don't expose record and replay on our scripts yet since it was was not very stable, but we will do so when it stabilizes.
6530+
6531+
<<rand_check-out>> is a good way to test out if record and replay is actually deterministic.
6532+
65126533
Alternatively, https://github.com/mozilla/rr[`mozilla/rr`] claims it is able to run QEMU: but using it would require you to step through QEMU code itself. Likely doable, but do you really want to?
65136534

65146535
==== QEMU trace multicore
@@ -8749,7 +8770,7 @@ Then proceed to do the following tests:
87498770
* `/count.sh` and `b __x64_sys_write`
87508771
* `insmod /timer.ko` and `b lkmc_timer_callback`
87518772

8752-
===== Sanity checks
8773+
==== Sanity checks
87538774

87548775
Basic C and C++ hello worlds:
87558776

@@ -8770,6 +8791,21 @@ Sources:
87708791
* link:kernel_module/user/hello.c[]
87718792
* link:kernel_module/user/hello_cpp.c[]
87728793

8794+
===== rand_check.out
8795+
8796+
Print out several parameters that normally change randomly from boot to boot:
8797+
8798+
....
8799+
./run -F '/rand_check.out;/poweroff.out'
8800+
....
8801+
8802+
Source: link:kernel_module/user/rand_check.c[]
8803+
8804+
This can be used to check the determinism of:
8805+
8806+
* <<norandmaps>>
8807+
* <<qemu-record-and-replay>>
8808+
87738809
=== About
87748810

87758811
This project is for people who want to learn and modify low level system components:

kernel_module/user/README.adoc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
https://github.com/cirosantilli/linux-kernel-module-cheat#rootfs_overlay
22

3-
. link:hello.c[]
4-
. link:hello_cpp.cpp[]
53
. link:sched_getaffinity.c[]
64
. link:usermem.c[]
75
.. link:pagemap_dump.c[]
8-
. inits
9-
... link:sleep_forever.c[]
10-
... link:poweroff.c[]
11-
... link:init_dev_kmsg.c[]
126
. link:uio_read.c[]
13-
. link:rand_check.c[]
14-
. x86_64
15-
.. link:rdtsc.c[]

kernel_module/user/rand_check.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
/* Check if we were able to remove certain sources of randomness
2-
* across boots using different techniques:
3-
*
4-
* - QEMU icount record replay
5-
* - norandmaps boot parameter
6-
*
7-
* You might want to run this as the init process to further remove undeterminism. */
1+
/* https://github.com/cirosantilli/linux-kernel-module-cheat#rand_check-out */
82

93
#include <inttypes.h>
104
#include <signal.h>

run

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ debug_vm=
99
debug=false
1010
kgdb=false
1111
kvm=false
12-
# norandmaps: Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space.
1312
# nokaslr:
1413
# - https://unix.stackexchange.com/questions/397939/turning-off-kaslr-to-debug-linux-kernel-using-qemu-and-gdb
1514
# - https://stackoverflow.com/questions/44612822/unable-to-debug-kernel-with-qemu-gdb/49840927#49840927

0 commit comments

Comments
 (0)