diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-12-02 19:50:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-02 19:50:27 +0100 |
| commit | ce1cd11efcd29052fda2f9e6d670c286e9c5021e (patch) | |
| tree | aa668a878fc78da2b1e5cb000fedfc3f3f89f5bd /csource/common.go | |
| parent | 3e53602346688d61fe5ea3a6fab6939a9d863d8f (diff) | |
| parent | 346fb4e5e977a0f0709a4fcdf9265f163fe32459 (diff) | |
Merge pull request #101 from xairy/tun-fix
executor: don't try to open tun if it's not enabled
Diffstat (limited to 'csource/common.go')
| -rw-r--r-- | csource/common.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/csource/common.go b/csource/common.go index 0cedc9920..17aa4b0ef 100644 --- a/csource/common.go +++ b/csource/common.go @@ -34,6 +34,7 @@ var commonHeader = ` #include <setjmp.h> #include <signal.h> #include <stdarg.h> +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> @@ -161,7 +162,7 @@ static void execute_command(const char* format, ...) va_end(args); } -int tunfd; +int tunfd = -1; #define ADDR_MAX_LEN 32 @@ -222,6 +223,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); @@ -351,7 +355,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) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -361,7 +365,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"; |
