go: downloading cloud.google.com/go/batch v1.12.2 go: downloading cloud.google.com/go/profiler v0.4.3 go: downloading cloud.google.com/go/longrunning v0.6.7 go: downloading github.com/google/pprof v0.0.0-20250602020802-c6617b811d0e go: downloading golang.org/x/mod v0.25.0 ? github.com/google/syzkaller/dashboard/api [no test files] ok github.com/google/syzkaller/dashboard/app 5.356s ok github.com/google/syzkaller/dashboard/dashapi (cached) ok github.com/google/syzkaller/executor 2.237s ok github.com/google/syzkaller/pkg/asset 1.140s ok github.com/google/syzkaller/pkg/ast (cached) ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect 216.955s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 6.922s ? github.com/google/syzkaller/pkg/clangtool [no test files] ok github.com/google/syzkaller/pkg/compiler (cached) ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 6.650s ok github.com/google/syzkaller/pkg/cover 6.720s ok github.com/google/syzkaller/pkg/cover/backend 8.577s ok github.com/google/syzkaller/pkg/coveragedb 0.226s ? github.com/google/syzkaller/pkg/coveragedb/mocks [no test files] ? github.com/google/syzkaller/pkg/coveragedb/spannerclient [no test files] ok github.com/google/syzkaller/pkg/covermerger 4.386s ? github.com/google/syzkaller/pkg/covermerger/mocks [no test files] --- FAIL: TestGenerate (13.18s) --- FAIL: TestGenerate/openbsd/amd64 (0.01s) testutil.go:35: seed=1751458103073245602 testutil.go:35: seed=1751458103087117595 --- FAIL: TestGenerate/openbsd/amd64/0 (2.70s) csource_test.go:149: opts: {Threaded:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { if (setsid() == -1 && errno != EPERM) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {} memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); syz_open_pts(); } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :207:2: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2641837164 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/1 (3.28s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :355:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor621453319 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/2 (3.37s) csource_test.go:149: opts: {Threaded:true Repeat:false RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void loop(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :275:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2158680235 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/3 (3.54s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:10 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :355:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2299596391 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/11 (3.59s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static int tunfd = -1; #define MAX_TUN 8 #define TUN_IFACE "tap%d" #define MAX_TUN_IFACE_SIZE sizeof("tap2147483647") #define TUN_DEVICE "/dev/tap%d" #define MAX_TUN_DEVICE_SIZE sizeof("/dev/tap2147483647") #define LOCAL_MAC "aa:aa:aa:aa:aa:aa" #define REMOTE_MAC "aa:aa:aa:aa:aa:bb" #define LOCAL_IPV4 "172.20.%d.170" #define MAX_LOCAL_IPV4_SIZE sizeof("172.20.255.170") #define REMOTE_IPV4 "172.20.%d.187" #define MAX_REMOTE_IPV4_SIZE sizeof("172.20.255.187") #define LOCAL_IPV6 "fe80::%02xaa" #define MAX_LOCAL_IPV6_SIZE sizeof("fe80::ffaa") #define REMOTE_IPV6 "fe80::%02xbb" #define MAX_REMOTE_IPV6_SIZE sizeof("fe80::ffbb") static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv = vsnprintf(str, size, format, args); if (rv < 0) exit(1); if ((size_t)rv >= size) exit(1); } static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } #define COMMAND_MAX_LEN 128 #define PATH_PREFIX "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) static void execute_command(bool panic, const char* format, ...) { va_list args; va_start(args, format); char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; memcpy(command, PATH_PREFIX, PATH_PREFIX_LEN); vsnprintf_check(command + PATH_PREFIX_LEN, COMMAND_MAX_LEN, format, args); va_end(args); int rv = system(command); if (rv) { if (panic) exit(1); } } static void initialize_tun(int tun_id) { if (tun_id < 0 || tun_id >= MAX_TUN) exit(1); char tun_device[MAX_TUN_DEVICE_SIZE]; snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id); char tun_iface[MAX_TUN_IFACE_SIZE]; snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id); execute_command(0, "ifconfig %s destroy", tun_iface); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open %s: errno=%d\n", tun_device, errno); return; } const int kTunFd = 200; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; char local_mac[sizeof(LOCAL_MAC)]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC); execute_command(1, "ifconfig %s lladdr %s", tun_iface, local_mac); char local_ipv4[MAX_LOCAL_IPV4_SIZE]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id); execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4); char remote_mac[sizeof(REMOTE_MAC)]; char remote_ipv4[MAX_REMOTE_IPV4_SIZE]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC); snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id); execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac); char local_ipv6[MAX_LOCAL_IPV6_SIZE]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id); execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6); char remote_ipv6[MAX_REMOTE_IPV6_SIZE]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id); execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac); } static long syz_emit_ethernet(volatile long a0, volatile long a1) { if (tunfd < 0) return (uintptr_t)-1; size_t length = a0; const char* data = (char*)a1; return write(tunfd, data, length); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; exit(1); } return rv; } struct tcp_resources { uint32_t seq; uint32_t ack; }; static long syz_extract_tcp_res(volatile long a0, volatile long a1, volatile long a2) { if (tunfd < 0) return (uintptr_t)-1; char data[1000]; int rv = read_tun(&data[0], sizeof(data)); if (rv == -1) return (uintptr_t)-1; size_t length = rv; if (length < sizeof(struct ether_header)) return (uintptr_t)-1; struct ether_header* ethhdr = (struct ether_header*)&data[0]; struct tcphdr* tcphdr = 0; if (ethhdr->ether_type == htons(ETHERTYPE_IP)) { if (length < sizeof(struct ether_header) + sizeof(struct ip)) return (uintptr_t)-1; struct ip* iphdr = (struct ip*)&data[sizeof(struct ether_header)]; if (iphdr->ip_p != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + iphdr->ip_hl * 4 + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + iphdr->ip_hl * 4]; } else { if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr)) return (uintptr_t)-1; struct ip6_hdr* ipv6hdr = (struct ip6_hdr*)&data[sizeof(struct ether_header)]; if (ipv6hdr->ip6_nxt != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + sizeof(struct ip6_hdr)]; } struct tcp_resources* res = (struct tcp_resources*)a0; res->seq = htonl(ntohl(tcphdr->th_seq) + (uint32_t)a1); res->ack = htonl(ntohl(tcphdr->th_ack) + (uint32_t)a2); return 0; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); initialize_tun(procid); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: memset((void*)0x200000000000, 255, 6); memset((void*)0x200000000006, 170, 5); *(uint8_t*)0x20000000000b = 0xbb; *(uint16_t*)0x20000000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 3, 4, 12); *(uint16_t*)0x200000000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x200000000012, 7, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x200000000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x200000000012, 1, 4, 12); *(uint16_t*)0x200000000014 = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x200000000016, 8, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000016, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000017, 3, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x200000000017, 4, 2, 6); *(uint16_t*)0x200000000018 = htobe16(0xee); *(uint16_t*)0x20000000001a = htobe16(0x67); *(uint16_t*)0x20000000001c = htobe16(8); *(uint8_t*)0x20000000001e = 0x28; *(uint8_t*)0x20000000001f = 2; *(uint16_t*)0x200000000020 = htobe16(0); *(uint32_t*)0x200000000022 = htobe32(0xe0000001); *(uint32_t*)0x200000000026 = htobe32(-1); *(uint8_t*)0x20000000002a = 7; *(uint8_t*)0x20000000002b = 0xb; *(uint8_t*)0x20000000002c = 0; *(uint8_t*)0x20000000002d = 0xac; *(uint8_t*)0x20000000002e = 0x14; *(uint8_t*)0x20000000002f = 0; *(uint8_t*)0x200000000030 = 0xbb; *(uint32_t*)0x200000000031 = htobe32(-1); *(uint8_t*)0x200000000036 = 0; *(uint8_t*)0x200000000037 = 0; *(uint16_t*)0x200000000038 = htobe16(0); *(uint16_t*)0x20000000003a = htobe16(0x67); *(uint16_t*)0x20000000003c = htobe16(0); memcpy((void*)0x20000000003e, "\x3a\xda\x13\xcf\xaa\xca\xcb\x06\x3a\x0a\x00\xde\xcc\x06\x10\xcb\x1d\xfc\x13\x8a\xce\xd0\x93\x8b\x4f\xc4\xab\x8f\x20\xd3\x79\x8d\xaf\xc4\x3f\xfc\x92\x40\xc7\x19\xea\xda\x82\x7e\xb9\xe1\x66\x3b\x8f\x8a\xe8\x0d\x4d\x85\xb6\xbe\x06\x9a\x29\xe2\xe8\xd1\x25\xd9\xfd\xa9\x0d\x08\x47\x7b\x1d\x28\x6a\x8d\xd8\xcf\x94\xed\x87\x0c\xe3\xde\x47\x35\x8c\x24\x1d\x3b\x88\xb8\x35\x9d\x7b\x3c\x15\x11\xdf\x5e\x4f\x13\x8c\x65\x4c\x2b\x1d\x2f\x7e\x87\x8b\x46\xf7\xe3\x76\x7b\xa2\xc3\x6d\x93\x58\xc9\x18\xe2\xcb\x82\x8b\x16\x16\x64\x84\x68\xf8\xc4\x48\xbd\xad\x04\x11\x76\x3b\x44\x21\x25\x22\x5d\xbc\x45\x53\x36\x00\x4e\xab\x05\x30\xb8\x57\x1d\xf8\x87\x00\x52\x35\xce\xa4\x1a\x9e\x2b\x50\xbe\xe9\x6a\x1b\xc2\x03\x68\x82\xa0\x8f\x78\x4b\x5f\x59\x7d\x69\x87\x9a\xe0\x87\x50\x94\x03\x28\xe1\x19\xc8\xed\xb0\xa6\x55", 198); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x200000000036, 206); *(uint16_t*)0x200000000038 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x200000000016, 32); *(uint16_t*)0x200000000020 = csum_inet_digest(&csum_2); syz_emit_ethernet(/*len=*/0x104, /*packet=*/0x200000000000); break; case 11: syz_extract_tcp_res(/*res=*/0x200000000140, /*seq_inc=*/0x8001, /*ack_inc=*/0xfffff801); break; case 12: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :557:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor190692838 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/12 (3.88s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:false HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); do_sandbox_none(); return 0; } :302:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3243307711 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/15 (3.85s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:2 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :357:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1175138710 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/4 (3.90s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :355:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3236961739 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/9 (4.17s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:-9223372036854775808 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :355:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3579834431 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/6 (0.90s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:10 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: truncate(&(0x7f0000000000)='./file0\x00', 0x6) (fail_nth: 1) readlink(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)=""/71, 0x47) (async) r0 = dup(0xffffffffffffff9c) (rerun: 4) mknodat(r0, &(0x7f0000000100)='./file0\x00', 0x8, 0x4) mknodat(r0, &(0x7f0000000140)='./file0\x00', 0xc000, 0x200) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000180)={0x0, 0x0}, &(0x7f00000001c0)=0xc) getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000000200)={0x0, 0x0}, &(0x7f0000000240)=0xc) setreuid(r1, r2) setsockopt$sock_int(r0, 0xffff, 0x200, &(0x7f0000000280), 0x4) writev(0xffffffffffffffff, &(0x7f0000000400)=[{&(0x7f0000000300)="34f6206eb7526dd786e36f23b023e4232a4a491323307774a944a4558f1fe81539f625c1502c1452873bbefd790d0c90ef37c7290113347eb53714a9d8873e5ecd582a9c7a87f390f7e2caa3914b415c3fd53aeba179b4566efb8f1214bbddd3d27e1ac1b489fff5fc1c093565ac126cd65a45fe6b549fa879edac16a15ad6e63dead72faf52a67daf19a9f8b98ca0aed397782ddedf3ff50f364e134fe89b138aef2fb4ad5be8ce00dcf1850b01ebd21e79bf0d7cc9f38184af76998dfdbb95d2bdb3dcf727649dfd17e9b5adc5cca1aa7b164fe79a5d265b9d", 0xda}], 0x1) syz_emit_ethernet(0x104, &(0x7f0000000000)={@broadcast, @remote, [{[{0x88a8, 0x0, 0x0, 0x3}], {0x8100, 0x7, 0x0, 0x1}}], {@ipv4={0x800, {{0x8, 0x4, 0x3, 0x4, 0xee, 0x67, 0x8, 0x28, 0x2, 0x0, @multicast1, @broadcast, {[@rr={0x7, 0xb, 0x0, [@remote={0xac, 0x14, 0x0}, @broadcast]}]}}, @icmp=@echo_reply={0x0, 0x0, 0x0, 0x67, 0x0, "3ada13cfaacacb063a0a00decc0610cb1dfc138aced0938b4fc4ab8f20d3798dafc43ffc9240c719eada827eb9e1663b8f8ae80d4d85b6be069a29e2e8d125d9fda90d08477b1d286a8dd8cf94ed870ce3de47358c241d3b88b8359d7b3c1511df5e4f138c654c2b1d2f7e878b46f7e3767ba2c36d9358c918e2cb828b1616648468f8c448bdad0411763b442125225dbc455336004eab0530b8571df887005235cea41a9e2b50bee96a1bc2036882a08f784b5f597d69879ae08750940328e119c8edb0a655"}}}}}) syz_extract_tcp_res(&(0x7f0000000140), 0x8001, 0xfffff801) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 500); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 15000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "./file0\000", 8); inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0x200000000000, /*len=*/6); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(readlink))(/*path=*/0x200000000040, /*buf=*/0x200000000080, /*siz=*/0x47); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/0xffffff9c); } if (res != -1) r[0] = res; break; case 3: memcpy((void*)0x200000000100, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ break; case 4: memcpy((void*)0x200000000140, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000140, /*mode=S_IFSOCK*/0xc000, /*dev=*/0x200)); /* major = 2, minor = 0 */ break; case 5: *(uint32_t*)0x2000000001c0 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000180, /*optlen=*/0x2000000001c0); if (res != -1) r[1] = *(uint32_t*)0x200000000184; break; case 6: *(uint32_t*)0x200000000240 = 0xc; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000200, /*optlen=*/0x200000000240); if (res != -1) r[2] = *(uint32_t*)0x200000000204; break; case 7: ((intptr_t(*)(intptr_t,intptr_t))CAST(setreuid))(/*ruid=*/r[1], /*euid=*/r[2]); break; case 8: *(uint32_t*)0x200000000280 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=SO_REUSEPORT*/0x200, /*optval=*/0x200000000280, /*optlen=*/4); break; case 9: *(uint64_t*)0x200000000400 = 0x200000000300; memcpy((void*)0x200000000300, "\x34\xf6\x20\x6e\xb7\x52\x6d\xd7\x86\xe3\x6f\x23\xb0\x23\xe4\x23\x2a\x4a\x49\x13\x23\x30\x77\x74\xa9\x44\xa4\x55\x8f\x1f\xe8\x15\x39\xf6\x25\xc1\x50\x2c\x14\x52\x87\x3b\xbe\xfd\x79\x0d\x0c\x90\xef\x37\xc7\x29\x01\x13\x34\x7e\xb5\x37\x14\xa9\xd8\x87\x3e\x5e\xcd\x58\x2a\x9c\x7a\x87\xf3\x90\xf7\xe2\xca\xa3\x91\x4b\x41\x5c\x3f\xd5\x3a\xeb\xa1\x79\xb4\x56\x6e\xfb\x8f\x12\x14\xbb\xdd\xd3\xd2\x7e\x1a\xc1\xb4\x89\xff\xf5\xfc\x1c\x09\x35\x65\xac\x12\x6c\xd6\x5a\x45\xfe\x6b\x54\x9f\xa8\x79\xed\xac\x16\xa1\x5a\xd6\xe6\x3d\xea\xd7\x2f\xaf\x52\xa6\x7d\xaf\x19\xa9\xf8\xb9\x8c\xa0\xae\xd3\x97\x78\x2d\xde\xdf\x3f\xf5\x0f\x36\x4e\x13\x4f\xe8\x9b\x13\x8a\xef\x2f\xb4\xad\x5b\xe8\xce\x00\xdc\xf1\x85\x0b\x01\xeb\xd2\x1e\x79\xbf\x0d\x7c\xc9\xf3\x81\x84\xaf\x76\x99\x8d\xfd\xbb\x95\xd2\xbd\xb3\xdc\xf7\x27\x64\x9d\xfd\x17\xe9\xb5\xad\xc5\xcc\xa1\xaa\x7b\x16\x4f\xe7\x9a\x5d\x26\x5b\x9d", 218); *(uint64_t*)0x200000000408 = 0xda; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/-1, /*vec=*/0x200000000400, /*vlen=*/1); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :355:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000100, /*mode=*/8, /*dev=*/4)); /* major = 0, minor = 4 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3371698421 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/8 (1.00s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/10 (3.66s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/7 (2.93s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/5 (3.17s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/14 (3.18s) csource_test.go:147: FAIL FAIL github.com/google/syzkaller/pkg/csource 28.113s ok github.com/google/syzkaller/pkg/db (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/declextract [no test files] ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore (cached) ok github.com/google/syzkaller/pkg/flatrpc 0.406s ok github.com/google/syzkaller/pkg/fuzzer 11.081s ok github.com/google/syzkaller/pkg/fuzzer/queue (cached) ok github.com/google/syzkaller/pkg/gce 0.351s ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/gcs/mocks [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ? github.com/google/syzkaller/pkg/html [no test files] ok github.com/google/syzkaller/pkg/html/pages (cached) ok github.com/google/syzkaller/pkg/html/urlutil (cached) ? github.com/google/syzkaller/pkg/ifaceprobe [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/ifuzz/arm64 (cached) ? github.com/google/syzkaller/pkg/ifuzz/arm64/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/arm64/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ok github.com/google/syzkaller/pkg/image (cached) ok github.com/google/syzkaller/pkg/instance 11.634s ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/pkg/kconfig (cached) ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/manager 12.928s ok github.com/google/syzkaller/pkg/mgrconfig 13.594s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 27.890s ? github.com/google/syzkaller/pkg/report/crash [no test files] ok github.com/google/syzkaller/pkg/repro 15.955s ok github.com/google/syzkaller/pkg/rpcserver 12.119s ? github.com/google/syzkaller/pkg/rpcserver/mocks [no test files] ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 52.325s ok github.com/google/syzkaller/pkg/serializer (cached) ok github.com/google/syzkaller/pkg/signal (cached) ok github.com/google/syzkaller/pkg/stat (cached) ok github.com/google/syzkaller/pkg/stat/sample 0.171s ? github.com/google/syzkaller/pkg/stat/syzbotstats [no test files] ok github.com/google/syzkaller/pkg/subsystem (cached) ok github.com/google/syzkaller/pkg/subsystem/linux (cached) ok github.com/google/syzkaller/pkg/subsystem/lists (cached) ok github.com/google/syzkaller/pkg/symbolizer (cached) ? github.com/google/syzkaller/pkg/testutil [no test files] ok github.com/google/syzkaller/pkg/tool (cached) ? github.com/google/syzkaller/pkg/tools [no test files] ok github.com/google/syzkaller/pkg/validator 1.389s ok github.com/google/syzkaller/pkg/vcs 141.961s ok github.com/google/syzkaller/pkg/vminfo (cached) ok github.com/google/syzkaller/prog (cached) ok github.com/google/syzkaller/prog/test (cached) ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? github.com/google/syzkaller/sys/generated [no test files] ok github.com/google/syzkaller/sys/linux (cached) ok github.com/google/syzkaller/sys/netbsd (cached) ok github.com/google/syzkaller/sys/openbsd (cached) ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ok github.com/google/syzkaller/syz-ci 77.195s ok github.com/google/syzkaller/syz-cluster/controller 1.268s ? github.com/google/syzkaller/syz-cluster/dashboard [no test files] ? github.com/google/syzkaller/syz-cluster/db-mgmt [no test files] ok github.com/google/syzkaller/syz-cluster/email-reporter 0.773s ? github.com/google/syzkaller/syz-cluster/pkg/api [no test files] ? github.com/google/syzkaller/syz-cluster/pkg/app [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/blob 0.550s ok github.com/google/syzkaller/syz-cluster/pkg/controller 0.381s ok github.com/google/syzkaller/syz-cluster/pkg/db 0.908s ok github.com/google/syzkaller/syz-cluster/pkg/report 0.629s ok github.com/google/syzkaller/syz-cluster/pkg/reporter 1.142s ? github.com/google/syzkaller/syz-cluster/pkg/service [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/triage (cached) ? github.com/google/syzkaller/syz-cluster/pkg/workflow [no test files] ? github.com/google/syzkaller/syz-cluster/reporter-server [no test files] ok github.com/google/syzkaller/syz-cluster/series-tracker 0.590s ? github.com/google/syzkaller/syz-cluster/workflow/boot-step [no test files] ? github.com/google/syzkaller/syz-cluster/workflow/build-step [no test files] ok github.com/google/syzkaller/syz-cluster/workflow/fuzz-step 14.463s ? github.com/google/syzkaller/syz-cluster/workflow/triage-step [no test files] ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager 9.154s ? github.com/google/syzkaller/tools/arm64 [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-covermerger [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ok github.com/google/syzkaller/tools/syz-db (cached) ? github.com/google/syzkaller/tools/syz-db-export [no test files] ok github.com/google/syzkaller/tools/syz-declextract 9.099s ? github.com/google/syzkaller/tools/syz-diff [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fillreports [no test files] ? github.com/google/syzkaller/tools/syz-fix-analyzer [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-gemini-seed [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ok github.com/google/syzkaller/tools/syz-kconf 9.259s ok github.com/google/syzkaller/tools/syz-linter 7.586s ? github.com/google/syzkaller/tools/syz-lore [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ok github.com/google/syzkaller/tools/syz-testbed 10.078s ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/parser (cached) ok github.com/google/syzkaller/tools/syz-trace2syz/proggen (cached) ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ok github.com/google/syzkaller/vm 17.262s ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? github.com/google/syzkaller/vm/cuttlefish [no test files] ok github.com/google/syzkaller/vm/dispatcher (cached) ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ok github.com/google/syzkaller/vm/isolated 6.654s ok github.com/google/syzkaller/vm/proxyapp 10.695s ? github.com/google/syzkaller/vm/proxyapp/mocks [no test files] ? github.com/google/syzkaller/vm/proxyapp/proxyrpc [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ? github.com/google/syzkaller/vm/starnix [no test files] ok github.com/google/syzkaller/vm/vmimpl 7.060s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL