mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
update to qemu v2.9.0! rand_check.c, init_forward.sh
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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)
|
||||
|
||||
41
kernel_module/user/rand_check.c
Normal file
41
kernel_module/user/rand_check.c
Normal file
@@ -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 <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
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);
|
||||
}
|
||||
2
qemu
2
qemu
Submodule qemu updated: 93203c1d8b...e583d175e4
@@ -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)
|
||||
|
||||
6
rootfs_overlay/init_forward.sh
Executable file
6
rootfs_overlay/init_forward.sh
Executable file
@@ -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 "$@"
|
||||
Reference in New Issue
Block a user