diff options
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common.h | 11 | ||||
| -rw-r--r-- | executor/executor.cc | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/executor/common.h b/executor/common.h index 8df0ee1ae..19da79b5e 100644 --- a/executor/common.h +++ b/executor/common.h @@ -33,6 +33,7 @@ #include <setjmp.h> #include <signal.h> #include <stdarg.h> +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> @@ -163,7 +164,7 @@ static void execute_command(const char* format, ...) va_end(args); } -int tunfd; +int tunfd = -1; #define ADDR_MAX_LEN 32 @@ -224,6 +225,9 @@ static void initialize_tun(uint64_t pid) static uintptr_t syz_emit_ethernet(uintptr_t a0, uintptr_t a1) { + if (tunfd < 0) + return (uintptr_t)-1; + int64_t length = a0; char* data = (char*)a1; return write(tunfd, data, length); @@ -361,7 +365,7 @@ static uintptr_t execute_syscall(int nr, uintptr_t a0, uintptr_t a1, uintptr_t a } } -static void setup_main_process(uint64_t pid) +static void setup_main_process(uint64_t pid, bool enable_tun) { // Don't need that SIGCANCEL/SIGSETXID glibc stuff. // SIGCANCEL sent to main thread causes it to exit @@ -374,7 +378,8 @@ static void setup_main_process(uint64_t pid) install_segv_handler(); #ifdef __NR_syz_emit_ethernet - initialize_tun(pid); + if (enable_tun) + initialize_tun(pid); #endif char tmpdir_template[] = "./syzkaller.XXXXXX"; diff --git a/executor/executor.cc b/executor/executor.cc index 85133fa3d..a51bd2e46 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -73,6 +73,7 @@ bool flag_collide; bool flag_deduplicate; bool flag_sandbox_privs; sandbox_type flag_sandbox; +bool flag_enable_tun; __attribute__((aligned(64 << 10))) char input_data[kMaxInput]; __attribute__((aligned(64 << 10))) char output_data[kMaxOutput]; @@ -161,10 +162,11 @@ int main(int argc, char** argv) flag_sandbox = sandbox_namespace; if (!flag_threaded) flag_collide = false; + flag_enable_tun = flags & (1 << 7); uint64_t executor_pid = *((uint64_t*)input_data + 1); cover_open(); - setup_main_process(executor_pid); + setup_main_process(executor_pid, flag_enable_tun); int pid = -1; switch (flag_sandbox) { |
