diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2021-04-22 16:13:56 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-04-22 18:34:47 +0200 |
| commit | 590921a5bc7ed9ced1d4c5cb517e4b6355813a5d (patch) | |
| tree | 97c874599d315f1185ba254e8b25ccf3f1a485c4 /executor/common_linux.h | |
| parent | 33c28d0389a6b0dd17a5de7c093a011cdadb33b1 (diff) | |
executor: set ctrl-alt-del sysctl to 0
This blocks some of the ways the fuzzer can trigger a reboot.
ctrl-alt-del=0 tells kernel to signal cad_pid instead of rebooting
and setting cad_pid to the current pid (transient "syz-executor setup") makes it a no-op.
For context see: https://groups.google.com/g/syzkaller-bugs/c/WqOY4TiRnFg/m/6P9u8lWZAQAJ
Diffstat (limited to 'executor/common_linux.h')
| -rw-r--r-- | executor/common_linux.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index 178298278..3e3879370 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -4626,13 +4626,17 @@ static void setup_usb() #if SYZ_EXECUTOR || SYZ_SYSCTL #include <errno.h> +#include <stdio.h> #include <string.h> static void setup_sysctl() { + char mypid[32]; + snprintf(mypid, sizeof(mypid), "%d", getpid()); + // TODO: consider moving all sysctl's into CMDLINE config later. // Kernel has support for setting sysctl's via command line since 3db978d480e28 (v5.8). - static struct { + struct { const char* name; const char* data; } files[] = { @@ -4668,6 +4672,12 @@ static void setup_sysctl() // We always want to prefer killing the allocating test process rather than somebody else // (sshd or another random test process). {"/proc/sys/vm/oom_kill_allocating_task", "1"}, + // This blocks some of the ways the fuzzer can trigger a reboot. + // ctrl-alt-del=0 tells kernel to signal cad_pid instead of rebooting + // and setting cad_pid to the current pid (transient "syz-executor setup") makes it a no-op. + // For context see: https://groups.google.com/g/syzkaller-bugs/c/WqOY4TiRnFg/m/6P9u8lWZAQAJ + {"/proc/sys/kernel/ctrl-alt-del", "0"}, + {"/proc/sys/kernel/cad_pid", mypid}, }; for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].name, files[i].data)) |
