From 62976c688b92151191a4b3d80d514ad09f75d349 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sat, 7 Oct 2017 04:11:08 +0100 Subject: [PATCH] update to qemu v2.9.0! rand_check.c, init_forward.sh --- README.md | 2 ++ kernel_module/user/README.md | 1 + kernel_module/user/rand_check.c | 41 +++++++++++++++++++++++++++++++++ qemu | 2 +- rootfs_overlay/README.md | 4 ---- rootfs_overlay/init_forward.sh | 6 +++++ 6 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 kernel_module/user/rand_check.c create mode 100755 rootfs_overlay/init_forward.sh diff --git a/README.md b/README.md index e1eb805..fc9dbbe 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,8 @@ and they will be run automatically before the login prompt. For convenience, we also setup a symlink from `S99` to `rootfs_overlay/etc/init.d/S99`. +Scripts under `/etc/init.d` are run by `/etc/init.d/rcS`, which gets called by the line `::sysinit:/etc/init.d/rcS` in `/etc/inittab`. + ### Custom init Is the default BusyBox `/init` too bloated for you, minimalism freak? diff --git a/kernel_module/user/README.md b/kernel_module/user/README.md index 14df18a..8e04599 100644 --- a/kernel_module/user/README.md +++ b/kernel_module/user/README.md @@ -18,6 +18,7 @@ These programs can also be compiled and used on host. 1. [poweroff](poweroff.c) 1. [init_dev_kmsg](init_dev_kmsg.c) 1. [uio_read](uio_read.c) + 1. [rand_check](rand_check.c) 1. Module tests 1. [anonymous_inode](anonymous_inode.c) 1. [poll](poll.c) diff --git a/kernel_module/user/rand_check.c b/kernel_module/user/rand_check.c new file mode 100644 index 0000000..4b8309c --- /dev/null +++ b/kernel_module/user/rand_check.c @@ -0,0 +1,41 @@ +/* Check if we were able to remove certain sources of randomness + * across boots using different techniques: + * + * - QEMU icount record replay + * - norandmaps boot parameter + * + * You might want to run this as the init process to further remove undeterminism. */ + +#include +#include +#include +#include +#include +#include + +int bss = 0; +int data = 1; + +int main(__attribute__((unused)) int argc, char **argv) { + int i, *ip; + uint64_t uint64; + FILE *fp; + + printf("time(NULL) = %ju\n", (uintmax_t)time(NULL)); + printf("&i = %p\n", (void *)&i); + printf("&argv[0] = %p\n", (void *)&argv[0]); + printf("&main = %p\n", (void *)(intptr_t)main); + printf("&bss = %p\n", (void *)&bss); + printf("&data = %p\n", (void *)&data); + + /* malloc */ + ip = malloc(sizeof(*ip)); + printf("&malloc = %p\n", (void *)ip); + free(ip); + + /* /dev/urandom */ + fp = fopen("/dev/urandom", "rb"); + fread(&uint64, sizeof(uint64), 1, fp); + printf("/dev/urandom = %" PRIx64 "\n", uint64); + fclose(fp); +} diff --git a/qemu b/qemu index 93203c1..e583d17 160000 --- a/qemu +++ b/qemu @@ -1 +1 @@ -Subproject commit 93203c1d8b7bd5c12896157802c89447d7d6a499 +Subproject commit e583d175e4cdfb12b4812a259e45c679743b32ad diff --git a/rootfs_overlay/README.md b/rootfs_overlay/README.md index b021b44..1bdc972 100644 --- a/rootfs_overlay/README.md +++ b/rootfs_overlay/README.md @@ -6,7 +6,3 @@ We use it to for things like: - customized configuration files - userland module test scripts - -Most tests correspond clearly to a given kernel module, but the following ones don't: - -- [gpio](gpio.sh) diff --git a/rootfs_overlay/init_forward.sh b/rootfs_overlay/init_forward.sh new file mode 100755 index 0000000..7f683a0 --- /dev/null +++ b/rootfs_overlay/init_forward.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Failed attempt at debugging /init, because: +# init must be run as pid 1 +# Is this just a random BusyBox sanity check? +# - https://stackoverflow.com/questions/35019995/strace-init-process-pid-1-in-linux +/sbin/init "$@"