? github.com/google/syzkaller/dashboard/api [no test files] ok github.com/google/syzkaller/dashboard/app 0.683s ok github.com/google/syzkaller/dashboard/dashapi (cached) ok github.com/google/syzkaller/executor 1.397s ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 1.684s ok github.com/google/syzkaller/pkg/auth (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ? 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/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ? github.com/google/syzkaller/pkg/report/crash [no test files] ? github.com/google/syzkaller/pkg/rpcserver/mocks [no test files] ? github.com/google/syzkaller/pkg/rpctype [no test files] ? github.com/google/syzkaller/pkg/stat/syzbotstats [no test files] ? github.com/google/syzkaller/pkg/testutil [no test files] ? github.com/google/syzkaller/pkg/tools [no test files] ok github.com/google/syzkaller/pkg/bisect 192.515s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 7.666s ok github.com/google/syzkaller/pkg/compiler 17.223s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 1.195s ok github.com/google/syzkaller/pkg/cover 0.685s ok github.com/google/syzkaller/pkg/cover/backend 1.849s ok github.com/google/syzkaller/pkg/coveragedb (cached) ok github.com/google/syzkaller/pkg/covermerger (cached) --- FAIL: TestGenerate (17.15s) --- FAIL: TestGenerate/openbsd/amd64 (0.15s) testutil.go:33: seed=1730324601468578071 testutil.go:33: seed=1730324601615753971 --- FAIL: TestGenerate/openbsd/amd64/15 (1.52s) csource_test.go:151: 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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; } :412: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1503774265 -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/14 (1.56s) csource_test.go:151: 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:true LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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)) { } fprintf(stderr, "### start\n"); 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); fprintf(stderr, "### call=0 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); fprintf(stderr, "### call=1 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); fprintf(stderr, "### call=2 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[1] = res; break; case 4: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); fprintf(stderr, "### call=4 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); fprintf(stderr, "### call=5 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res != -1) r[2] = res; break; case 6: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); fprintf(stderr, "### call=6 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); fprintf(stderr, "### call=7 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); res = -1; errno = EFAULT; NONFAILING(res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ fprintf(stderr, "### call=8 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 9: *(uint32_t*)0x20000200 = 3; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); fprintf(stderr, "### call=9 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 10: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=10 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x20000000, /*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; } :433:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3042797274 -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 (1.64s) csource_test.go:151: 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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; } :410: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3966354895 -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 (1.82s) csource_test.go:151: 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); break; case 10: memset((void*)0x20000000, 170, 5); *(uint8_t*)0x20000005 = 0xbb; memset((void*)0x20000006, 0, 6); *(uint16_t*)0x2000000c = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x2000000e, 7, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x2000000e, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x2000000e, 4, 4, 12); *(uint16_t*)0x20000010 = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x20000012, 0xb, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x20000012, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x20000013, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x20000013, 3, 2, 6); *(uint16_t*)0x20000014 = htobe16(0xe5); *(uint16_t*)0x20000016 = htobe16(0x68); *(uint16_t*)0x20000018 = htobe16(2); *(uint8_t*)0x2000001a = 2; *(uint8_t*)0x2000001b = 0x3c; *(uint16_t*)0x2000001c = htobe16(0); *(uint32_t*)0x2000001e = htobe32(0xfffff97b); *(uint32_t*)0x20000022 = htobe32(4); *(uint8_t*)0x20000026 = 1; *(uint8_t*)0x20000027 = 0x83; *(uint8_t*)0x20000028 = 0xf; *(uint8_t*)0x20000029 = 0; *(uint32_t*)0x2000002a = htobe32(-1); *(uint8_t*)0x2000002e = 0xac; *(uint8_t*)0x2000002f = 0x14; *(uint8_t*)0x20000030 = 0; *(uint8_t*)0x20000031 = 0xaa; *(uint32_t*)0x20000032 = htobe32(0xf); *(uint8_t*)0x20000036 = 7; *(uint8_t*)0x20000037 = 7; *(uint8_t*)0x20000038 = 1; *(uint32_t*)0x20000039 = htobe32(0); *(uint16_t*)0x2000003e = htobe16(0x4e20); *(uint16_t*)0x20000040 = htobe16(0x4e22); *(uint16_t*)0x20000042 = htobe16(8); *(uint16_t*)0x20000044 = htobe16(0); memcpy((void*)0x20000046, "\x11\xbe\xd3\xa7\x3e\x37\x33\x2c\x5b\x72\x55\xde\x7c\x5c\x5d\xd6\x02\xa1\xd2\x6b\x7b\xc2\x50\xd2\x8e\x8a\xae\x8e\x1f\x49\x6f\xa0\x0b\x25\xf5\xdf\x5b\xf5\xe7\x51\xfa\xd6\xa0\x78\x75\xa1\x7a\xf7\x77\x01\x66\x39\x16\xfa\x7f\x15\x1f\x9d\x06\xdb\x95\x44\x3d\xea\x4b\x21\x8a\x71\x3d\xd9\x07\x5e\x48\x05\x86\x95\x97\xa7\x9c\xac\x86\x06\xa5\xe0\xae\x7a\xfd\x8b\xb3\xe3\x85\x02\xae\xf5\xd2\x63\xa5\x06\xc9\xfb\x84\x14\xc6\xa4\x16\xe0\xb7\xbc\x33\x4f\x6d\x96\x47\x8e\x16\xff\xc3\x93\x6e\x68\x6f\xa0\x82\x19\x75\x9d\x8d\x40\x80\x0a\x64\x1a\x01\xf3\x19\xfc\x73\x07\xe9\xc0\x8b\x72\x4e\x90\xc2\x36\x55\xc7\x1b\xd2\xc8\x28\x7a\xaf\x8e\x9a\x08\xd1\xbd\x1e\xe1\x85\x9e\x4c\xbf\x54\x96\x1e\x3d\xcd\xfe\x2b\x5a\xf1\xfd\x9b\xa9", 177); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x2000001e, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000022, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x2000003e, 8); *(uint16_t*)0x20000044 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x20000012, 44); *(uint16_t*)0x2000001c = csum_inet_digest(&csum_2); syz_emit_ethernet(/*len=*/0xf7, /*packet=*/0x20000000); break; case 11: syz_extract_tcp_res(/*res=*/0x20000100, /*seq_inc=*/0x8000, /*ack_inc=*/0); 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=*/0x20000000, /*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; } :612: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3958850275 -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 (1.89s) csource_test.go:151: 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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; } :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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4145449782 -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/10 (1.84s) csource_test.go:151: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:9223372036854775807 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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; } :410: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1954122914 -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 (2.12s) csource_test.go:151: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:setuid 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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 wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, WUNTRACED) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_setuid(void) { int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); char pwbuf[1024]; struct passwd *pw, pwres; if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw) exit(1); if (setgroups(0, NULL)) exit(1); if (setgid(pw->pw_gid)) exit(1); if (setuid(pw->pw_uid)) exit(1); loop(); exit(1); } 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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_setuid(); return 0; } :433: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor620948539 -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 (0.91s) csource_test.go:151: 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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; } :330: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1298232207 -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 (1.12s) csource_test.go:151: 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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; } :410: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3327521197 -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/5 (3.03s) csource_test.go:151: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:4 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: r0 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000000), 0x200, 0x0) (fail_nth: 1) ioctl$WSKBDIO_SETDEFAULTKEYREPEAT(r0, 0x800c5709, &(0x7f0000000040)={0x200, 0x8ee3, 0x1}) (async) ioctl$WSKBDIO_SETMAP(r0, 0x8010570e, &(0x7f00000000c0)={0x5, &(0x7f0000000080)=[{0x5, 0x0, 0x1, 0x7, 0x1}, {0x4, 0x8, 0x4, 0x2, 0x1}, {0x0, 0x1, 0x175, 0xffff, 0x4}, {0x2, 0xb8, 0x6, 0x4, 0x8}, {0xffff, 0x9, 0xfe1, 0x8, 0x5}]}) (rerun: 4) r1 = syz_open_pts() ioctl$TIOCSCTTY(r1, 0x20007461) r2 = openat$wskbd(0xffffffffffffff9c, &(0x7f0000000100), 0x100, 0x0) ioctl$WSKBDIO_GETDEFAULTKEYREPEAT(r2, 0x400c570a, &(0x7f0000000140)) r3 = open$dir(&(0x7f0000000180)='./file0\x00', 0x80, 0x40) mknodat(r3, &(0x7f00000001c0)='./file0\x00', 0x2000, 0x3) ioctl$FIOSETOWN(0xffffffffffffff9c, 0x8004667c, &(0x7f0000000200)=0x3) syz_emit_ethernet(0xf7, &(0x7f0000000000)={@remote, @empty, [{[], {0x8100, 0x7, 0x1, 0x4}}], {@ipv4={0x800, {{0xb, 0x4, 0x2, 0x3, 0xe5, 0x68, 0x2, 0x2, 0x3c, 0x0, @rand_addr=0xfffff97b, @rand_addr=0x4, {[@noop, @lsrr={0x83, 0xf, 0x0, [@broadcast, @local={0xac, 0x14, 0x0}, @rand_addr=0xf]}, @rr={0x7, 0x7, 0x1, [@empty]}]}}, @udp={{0x0, 0x2, 0x8}, {"11bed3a73e37332c5b7255de7c5c5dd602a1d26b7bc250d28e8aae8e1f496fa00b25f5df5bf5e751fad6a07875a17af77701663916fa7f151f9d06db95443dea4b218a713dd9075e4805869597a79cac8606a5e0ae7afd8bb3e38502aef5d263a506c9fb8414c6a416e0b7bc334f6d96478e16ffc3936e686fa08219759d8d40800a641a01f319fc7307e9c08b724e90c23655c71bd2c8287aaf8e9a08d1bd1ee1859e4cbf54961e3dcdfe2b5af1fd9ba9"}}}}}}) syz_extract_tcp_res(&(0x7f0000000100), 0x8000, 0x0) syz_open_pts() csource_test.go:152: 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000000, "/dev/wskbd0\000", 12); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000000, /*flags=O_CREAT*/0x200, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x20000040 = 0x200; *(uint32_t*)0x20000044 = 0x8ee3; *(uint32_t*)0x20000048 = 1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x800c5709, /*arg=*/0x20000040); break; case 2: *(uint32_t*)0x200000c0 = 5; *(uint64_t*)0x200000c8 = 0x20000080; *(uint16_t*)0x20000080 = 5; *(uint16_t*)0x20000082 = 0; *(uint16_t*)0x20000084 = 1; *(uint16_t*)0x20000086 = 7; *(uint16_t*)0x20000088 = 1; *(uint16_t*)0x2000008a = 4; *(uint16_t*)0x2000008c = 8; *(uint16_t*)0x2000008e = 4; *(uint16_t*)0x20000090 = 2; *(uint16_t*)0x20000092 = 1; *(uint16_t*)0x20000094 = 0; *(uint16_t*)0x20000096 = 1; *(uint16_t*)0x20000098 = 0x175; *(uint16_t*)0x2000009a = -1; *(uint16_t*)0x2000009c = 4; *(uint16_t*)0x2000009e = 2; *(uint16_t*)0x200000a0 = 0xb8; *(uint16_t*)0x200000a2 = 6; *(uint16_t*)0x200000a4 = 4; *(uint16_t*)0x200000a6 = 8; *(uint16_t*)0x200000a8 = -1; *(uint16_t*)0x200000aa = 9; *(uint16_t*)0x200000ac = 0xfe1; *(uint16_t*)0x200000ae = 8; *(uint16_t*)0x200000b0 = 5; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x8010570e, /*arg=*/0x200000c0); } break; case 3: res = -1; res = syz_open_pts(); if (res != -1) r[1] = res; break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[1], /*cmd=*/0x20007461, 0); break; case 5: memcpy((void*)0x20000100, "/dev/wskbd0\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000100, /*flags=O_NOFOLLOW*/0x100, /*mode=*/0); if (res != -1) r[2] = res; break; case 6: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x400c570a, /*arg=*/0x20000140); break; case 7: memcpy((void*)0x20000180, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000180, /*flags=O_RSYNC*/0x80, /*mode=S_IXUSR*/0x40); if (res != -1) r[3] = res; break; case 8: memcpy((void*)0x200001c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ break; case 9: *(uint32_t*)0x20000200 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/0xffffff9c, /*cmd=*/0x8004667c, /*arg=*/0x20000200); 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=*/0x20000000, /*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 < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :412: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[3], /*file=*/0x200001c0, /*mode=S_IFCHR*/0x2000, /*dev=*/3)); /* major = 0, minor = 3 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4285541476 -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/0 (3.19s) csource_test.go:149: --- FAIL: TestGenerate/openbsd/amd64/4 (1.78s) csource_test.go:149: --- FAIL: TestGenerate/openbsd/amd64/3 (1.51s) csource_test.go:149: --- FAIL: TestGenerate/openbsd/amd64/7 (1.60s) csource_test.go:149: --- FAIL: TestGenerate/openbsd/amd64/1 (1.87s) csource_test.go:149: FAIL FAIL github.com/google/syzkaller/pkg/csource 22.416s ok github.com/google/syzkaller/pkg/db (cached) ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore (cached) ok github.com/google/syzkaller/pkg/flatrpc (cached) ok github.com/google/syzkaller/pkg/fuzzer 11.484s ok github.com/google/syzkaller/pkg/fuzzer/queue (cached) ok github.com/google/syzkaller/pkg/gce (cached) ok github.com/google/syzkaller/pkg/html (cached) ok github.com/google/syzkaller/pkg/html/pages (cached) ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/ifuzz/arm64 (cached) ok github.com/google/syzkaller/pkg/image 5.829s ok github.com/google/syzkaller/pkg/instance 18.175s 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 17.835s ok github.com/google/syzkaller/pkg/mgrconfig 20.736s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 33.599s ok github.com/google/syzkaller/pkg/repro 16.635s ok github.com/google/syzkaller/pkg/rpcserver 12.423s ok github.com/google/syzkaller/pkg/runtest 34.003s 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 (cached) 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) ok github.com/google/syzkaller/pkg/tool (cached) ok github.com/google/syzkaller/pkg/validator (cached) ok github.com/google/syzkaller/pkg/vcs (cached) ok github.com/google/syzkaller/pkg/vminfo 25.164s ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/darwin/gen [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? 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/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ? 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-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-covermerger [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-declextract [no test files] ? 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] ? 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-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ? 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] ? 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] ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ? 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] ? github.com/google/syzkaller/vm/vmware [no test files] ? github.com/google/syzkaller/vm/vmm [no test files] ok github.com/google/syzkaller/prog 54.888s ok github.com/google/syzkaller/prog/test (cached) ok github.com/google/syzkaller/sys/linux 1.426s ok github.com/google/syzkaller/sys/netbsd (cached) ok github.com/google/syzkaller/sys/openbsd (cached) ok github.com/google/syzkaller/syz-ci 36.371s ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager 6.644s ok github.com/google/syzkaller/tools/syz-kconf (cached) ok github.com/google/syzkaller/tools/syz-linter (cached) ok github.com/google/syzkaller/tools/syz-testbed 6.107s ok github.com/google/syzkaller/tools/syz-trace2syz/parser 0.332s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 2.556s ok github.com/google/syzkaller/vm 17.030s ok github.com/google/syzkaller/vm/dispatcher (cached) ok github.com/google/syzkaller/vm/isolated 5.019s ok github.com/google/syzkaller/vm/proxyapp 12.021s ok github.com/google/syzkaller/vm/vmimpl 4.779s FAIL