? github.com/google/syzkaller/dashboard/api [no test files] ok github.com/google/syzkaller/dashboard/app 7.749s ok github.com/google/syzkaller/dashboard/dashapi (cached) ok github.com/google/syzkaller/executor 2.828s ok github.com/google/syzkaller/pkg/asset 1.232s ok github.com/google/syzkaller/pkg/ast 2.756s ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect 232.560s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 6.378s ? github.com/google/syzkaller/pkg/clangtool [no test files] ok github.com/google/syzkaller/pkg/compiler 19.985s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 11.215s ok github.com/google/syzkaller/pkg/cover 10.495s ok github.com/google/syzkaller/pkg/cover/backend 10.994s ok github.com/google/syzkaller/pkg/coveragedb (cached) ? github.com/google/syzkaller/pkg/coveragedb/mocks [no test files] ? github.com/google/syzkaller/pkg/coveragedb/spannerclient [no test files] ok github.com/google/syzkaller/pkg/covermerger 2.641s ? github.com/google/syzkaller/pkg/covermerger/mocks [no test files] --- FAIL: TestGenerate (15.94s) --- FAIL: TestGenerate/openbsd/amd64 (0.03s) testutil.go:35: seed=1744921198612516203 testutil.go:35: seed=1744921198643194534 --- FAIL: TestGenerate/openbsd/amd64/14 (2.56s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:true LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } 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[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*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: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); fprintf(stderr, "### call=1 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); 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,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); fprintf(stderr, "### call=3 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); fprintf(stderr, "### call=4 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); fprintf(stderr, "### call=5 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); fprintf(stderr, "### call=6 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); fprintf(stderr, "### call=7 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); res = -1; errno = EFAULT; NONFAILING(res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ fprintf(stderr, "### call=8 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); 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=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :411: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[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2004778557 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/3 (2.64s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:10 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :385:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1416157645 -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 (2.81s) csource_test.go:149: 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$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :385:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1375952562 -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 (2.84s) csource_test.go:149: 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$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21 + procid*4; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :387:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2641109770 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/15 (3.04s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:2 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21 + procid*4; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :387:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2279464776 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/12 (3.47s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:false HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); do_sandbox_none(); return 0; } :332:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2661447471 -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 (3.59s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:-9223372036854775808 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :385:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3543250310 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/11 (3.71s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #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[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: memset((void*)0x200000000000, 170, 5); *(uint8_t*)0x200000000005 = 0xbb; memset((void*)0x200000000006, 0, 6); *(uint16_t*)0x20000000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 7, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 0, 4, 12); *(uint16_t*)0x200000000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x200000000012, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x200000000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x200000000012, 3, 4, 12); *(uint16_t*)0x200000000014 = htobe16(0x8010); memcpy((void*)0x200000000016, "\x81\x9f\x9f\x4d\xe0\x8f\xef\x51\xc5\xcc\x5c\x42\x0b\xf7\x0e\x31\x23\x8a\xdb\x1a\xb0\x2a\xce\x5a\x1e\x87\x30\x2a\x37\xbf\x03\xc6\x6f\x5e\x3f\xf7\x14\xa0\x6d\x69\xff\x43\xfc\xa4\xa8\x02\x9b\xed\xae\xf2\x7b\xf5\x61\xfd\x59\x9f\xe3\x41\xc3\x09\xfa\xa7\xdb\xb9\xa0\x80\xa7\x59\xb4\xc4\xb1\x97\x67\x8b\xaa\x3d\x0e\xf2\xf6\x1b\x42\x24\x06\x5e\x9e\xbd\xd7\x06\x55\x11\x7b\xeb\x43\x9b\xca\x7c\x84\x40\xc2\x5d\x95\xcd\x0a\x35\xb9\x1c\x8c\xf3\x52\x3a\x75\x68\xd0\xa7\xc5\x35\xee\x33", 118); syz_emit_ethernet(/*len=*/0x8c, /*packet=*/0x200000000000); break; case 11: syz_extract_tcp_res(/*res=*/0x2000000000c0, /*seq_inc=*/0x800, /*ack_inc=*/9); break; case 12: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :560:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4244188596 -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 (1.36s) csource_test.go:149: opts: {Threaded:true Repeat:false RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void loop(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); break; case 2: *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); break; case 4: *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); break; case 5: memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); break; case 6: memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); break; case 7: memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); break; case 8: memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ break; case 9: *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :305:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2172387894 -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.94s) csource_test.go:149: opts: {Threaded:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$null(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) (fail_nth: 1) pwrite(r0, &(0x7f0000000040)="c8516bd6c60d546bae7f73f2005efe8e3f5213839faad13d3478bccfe5ade62f2f03b2dacbeb475b17418d35602f349223e6c585da0f26c1be246f1a1f090abdcad26caeded7909dd1", 0x49, 0xffffffffffffffff) (async) recvfrom$unix(r0, &(0x7f00000000c0)=""/196, 0xc4, 0x800, &(0x7f00000001c0)=@abs={0x0, 0x0, 0x1}, 0x8) (rerun: 4) read(r0, &(0x7f0000000200)=""/167, 0xa7) ioctl$PCIOCWRITE(r0, 0xc0107003, &(0x7f00000002c0)={{0x1, 0x0, 0x34}, 0x0, 0x1ff, 0x400}) lstat(&(0x7f0000000300)='./file0\x00', &(0x7f0000000340)) sendto$unix(r0, &(0x7f00000003c0)="1d8f6d4b0b01e64d85c29bdf4725bbe4385d63ef4ff28d77b8a4aded3a1028816a8f865e7e87d29afc2b1e075ff90224963c63b87298ac34d8979f6a2b5b2660bf1f3da675e3fa968ea8b80ef8af6de015fc4a1186e18620b74a7de510e60506b02c7edc83bf0be53523ea0f8e8dc7bf60c080e6e3784bcb453db50657a83b3896a716fa84b35c7da7d0c4f6e8bd9984adb2178d29dbcf1889cb32ee71f2ae38db92f85ca2ec81a973677b07d12ca9562c", 0xb1, 0x400, &(0x7f0000000480)=@file={0x1, './file0\x00'}, 0xa) symlink(&(0x7f00000004c0)='./file0\x00', &(0x7f0000000500)='./file0/../file0\x00') mknodat(r0, &(0x7f0000000540)='./file0\x00', 0x2000, 0x8000) getsockname$inet6(r0, &(0x7f0000000580), &(0x7f00000005c0)=0xc) syz_emit_ethernet(0x8c, &(0x7f0000000000)={@remote, @empty, [{[{0x88a8, 0x7}], {0x8100, 0x4, 0x0, 0x3}}], {@generic={0x8010, "819f9f4de08fef51c5cc5c420bf70e31238adb1ab02ace5a1e87302a37bf03c66f5e3ff714a06d69ff43fca4a8029bedaef27bf561fd599fe341c309faa7dbb9a080a759b4c4b197678baa3d0ef2f61b4224065e9ebdd70655117beb439bca7c8440c25d95cd0a35b91c8cf3523a7568d0a7c535ee33"}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x800, 0x9) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { if (setsid() == -1 && errno != EPERM) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {} memcpy((void*)0x200000000000, "/dev/null\000", 10); inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000000, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; memcpy((void*)0x200000000040, "\xc8\x51\x6b\xd6\xc6\x0d\x54\x6b\xae\x7f\x73\xf2\x00\x5e\xfe\x8e\x3f\x52\x13\x83\x9f\xaa\xd1\x3d\x34\x78\xbc\xcf\xe5\xad\xe6\x2f\x2f\x03\xb2\xda\xcb\xeb\x47\x5b\x17\x41\x8d\x35\x60\x2f\x34\x92\x23\xe6\xc5\x85\xda\x0f\x26\xc1\xbe\x24\x6f\x1a\x1f\x09\x0a\xbd\xca\xd2\x6c\xae\xde\xd7\x90\x9d\xd1", 73); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(pwrite))(/*fd=*/r[0], /*buf=*/0x200000000040, /*nbyte=*/0x49, /*off=*/-1); *(uint16_t*)0x2000000001c0 = 0; *(uint8_t*)0x2000000001c2 = 0; *(uint32_t*)0x2000000001c4 = 0x4e21; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(recvfrom))(/*fd=*/r[0], /*buf=*/0x2000000000c0, /*len=*/0xc4, /*f=MSG_CMSG_CLOEXEC*/0x800, /*addr=*/0x2000000001c0, /*addrlen=*/8); } ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(read))(/*fd=*/r[0], /*buf=*/0x200000000200, /*count=*/0xa7); *(uint8_t*)0x2000000002c0 = 1; *(uint8_t*)0x2000000002c1 = 0; *(uint8_t*)0x2000000002c2 = 0x34; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0x1ff; *(uint32_t*)0x2000000002cc = 0x400; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc0107003, /*arg=*/0x2000000002c0); memcpy((void*)0x200000000300, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(lstat))(/*file=*/0x200000000300, /*statbuf=*/0x200000000340); memcpy((void*)0x2000000003c0, "\x1d\x8f\x6d\x4b\x0b\x01\xe6\x4d\x85\xc2\x9b\xdf\x47\x25\xbb\xe4\x38\x5d\x63\xef\x4f\xf2\x8d\x77\xb8\xa4\xad\xed\x3a\x10\x28\x81\x6a\x8f\x86\x5e\x7e\x87\xd2\x9a\xfc\x2b\x1e\x07\x5f\xf9\x02\x24\x96\x3c\x63\xb8\x72\x98\xac\x34\xd8\x97\x9f\x6a\x2b\x5b\x26\x60\xbf\x1f\x3d\xa6\x75\xe3\xfa\x96\x8e\xa8\xb8\x0e\xf8\xaf\x6d\xe0\x15\xfc\x4a\x11\x86\xe1\x86\x20\xb7\x4a\x7d\xe5\x10\xe6\x05\x06\xb0\x2c\x7e\xdc\x83\xbf\x0b\xe5\x35\x23\xea\x0f\x8e\x8d\xc7\xbf\x60\xc0\x80\xe6\xe3\x78\x4b\xcb\x45\x3d\xb5\x06\x57\xa8\x3b\x38\x96\xa7\x16\xfa\x84\xb3\x5c\x7d\xa7\xd0\xc4\xf6\xe8\xbd\x99\x84\xad\xb2\x17\x8d\x29\xdb\xcf\x18\x89\xcb\x32\xee\x71\xf2\xae\x38\xdb\x92\xf8\x5c\xa2\xec\x81\xa9\x73\x67\x7b\x07\xd1\x2c\xa9\x56\x2c", 177); *(uint16_t*)0x200000000480 = 1; memcpy((void*)0x200000000482, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(sendto))(/*fd=*/r[0], /*buf=*/0x2000000003c0, /*len=*/0xb1, /*f=MSG_NOSIGNAL*/0x400, /*addr=*/0x200000000480, /*addrlen=*/0xa); memcpy((void*)0x2000000004c0, "./file0\000", 8); memcpy((void*)0x200000000500, "./file0/../file0\000", 17); ((intptr_t(*)(intptr_t,intptr_t))CAST(symlink))(/*old=*/0x2000000004c0, /*new=*/0x200000000500); memcpy((void*)0x200000000540, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ *(uint32_t*)0x2000000005c0 = 0xc; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x200000000580, /*addrlen=*/0x2000000005c0); syz_open_pts(); } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :227:2: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000540, /*mode=S_IFCHR*/0x2000, /*dev=*/0x8000)); /* major = 128, minor = 0 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1985129713 -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.26s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/7 (1.60s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/4 (1.01s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/8 (1.93s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/1 (2.20s) csource_test.go:147: FAIL FAIL github.com/google/syzkaller/pkg/csource 32.293s ok github.com/google/syzkaller/pkg/db (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/declextract [no test files] ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore 0.717s ok github.com/google/syzkaller/pkg/flatrpc (cached) ok github.com/google/syzkaller/pkg/fuzzer 11.580s ok github.com/google/syzkaller/pkg/fuzzer/queue (cached) ok github.com/google/syzkaller/pkg/gce (cached) ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/gcs/mocks [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ? github.com/google/syzkaller/pkg/html [no test files] ok github.com/google/syzkaller/pkg/html/pages 0.437s ok github.com/google/syzkaller/pkg/html/urlutil (cached) ? github.com/google/syzkaller/pkg/ifaceprobe [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/ifuzz/arm64 (cached) ? github.com/google/syzkaller/pkg/ifuzz/arm64/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/arm64/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ok github.com/google/syzkaller/pkg/image 15.879s ok github.com/google/syzkaller/pkg/instance 13.185s ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/pkg/kconfig 0.346s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/manager 11.989s ok github.com/google/syzkaller/pkg/mgrconfig 14.808s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 29.886s ? github.com/google/syzkaller/pkg/report/crash [no test files] ok github.com/google/syzkaller/pkg/repro 11.668s ok github.com/google/syzkaller/pkg/rpcserver 12.778s ? github.com/google/syzkaller/pkg/rpcserver/mocks [no test files] ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 57.523s 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) ? github.com/google/syzkaller/pkg/stat/syzbotstats [no test files] ok github.com/google/syzkaller/pkg/subsystem (cached) ok github.com/google/syzkaller/pkg/subsystem/linux (cached) ok github.com/google/syzkaller/pkg/subsystem/lists (cached) ok github.com/google/syzkaller/pkg/symbolizer 1.188s ? github.com/google/syzkaller/pkg/testutil [no test files] ok github.com/google/syzkaller/pkg/tool 0.388s ? github.com/google/syzkaller/pkg/tools [no test files] ok github.com/google/syzkaller/pkg/validator (cached) ok github.com/google/syzkaller/pkg/vcs 142.935s ok github.com/google/syzkaller/pkg/vminfo 28.156s ok github.com/google/syzkaller/prog 126.260s ok github.com/google/syzkaller/prog/test 12.751s ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? github.com/google/syzkaller/sys/generated [no test files] ok github.com/google/syzkaller/sys/linux 13.817s ok github.com/google/syzkaller/sys/netbsd 12.917s ok github.com/google/syzkaller/sys/openbsd 11.721s ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ok github.com/google/syzkaller/syz-ci 78.747s ok github.com/google/syzkaller/syz-cluster/controller 1.921s ? github.com/google/syzkaller/syz-cluster/dashboard [no test files] ? github.com/google/syzkaller/syz-cluster/db-mgmt [no test files] ? github.com/google/syzkaller/syz-cluster/pkg/api [no test files] ? github.com/google/syzkaller/syz-cluster/pkg/app [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/blob (cached) ok github.com/google/syzkaller/syz-cluster/pkg/controller 1.507s ok github.com/google/syzkaller/syz-cluster/pkg/db 1.459s ok github.com/google/syzkaller/syz-cluster/pkg/report (cached) ? github.com/google/syzkaller/syz-cluster/pkg/service [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/triage 18.759s ? github.com/google/syzkaller/syz-cluster/pkg/workflow [no test files] ok github.com/google/syzkaller/syz-cluster/reporter 1.846s ok github.com/google/syzkaller/syz-cluster/series-tracker 1.536s ? github.com/google/syzkaller/syz-cluster/workflow/boot-step [no test files] ? github.com/google/syzkaller/syz-cluster/workflow/build-step [no test files] ok github.com/google/syzkaller/syz-cluster/workflow/fuzz-step 21.433s ? github.com/google/syzkaller/syz-cluster/workflow/triage-step [no test files] ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager 17.025s ? github.com/google/syzkaller/tools/arm64 [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-covermerger [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ok github.com/google/syzkaller/tools/syz-db 14.759s ? github.com/google/syzkaller/tools/syz-db-export [no test files] ok github.com/google/syzkaller/tools/syz-declextract 10.533s ? github.com/google/syzkaller/tools/syz-diff [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fillreports [no test files] ? github.com/google/syzkaller/tools/syz-fix-analyzer [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-gemini-seed [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ok github.com/google/syzkaller/tools/syz-kconf 9.429s ok github.com/google/syzkaller/tools/syz-linter (cached) ? github.com/google/syzkaller/tools/syz-lore [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ok github.com/google/syzkaller/tools/syz-testbed 7.866s ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/parser 6.905s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 9.083s ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ok github.com/google/syzkaller/vm 21.315s ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? github.com/google/syzkaller/vm/cuttlefish [no test files] ok github.com/google/syzkaller/vm/dispatcher (cached) ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ok github.com/google/syzkaller/vm/isolated 5.210s ok github.com/google/syzkaller/vm/proxyapp 8.911s ? github.com/google/syzkaller/vm/proxyapp/mocks [no test files] ? github.com/google/syzkaller/vm/proxyapp/proxyrpc [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ? github.com/google/syzkaller/vm/starnix [no test files] ok github.com/google/syzkaller/vm/vmimpl 5.370s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL