? github.com/google/syzkaller/dashboard/api [no test files] ok github.com/google/syzkaller/dashboard/app 9.216s ? github.com/google/syzkaller/dashboard/app/aidb [no test files] ok github.com/google/syzkaller/dashboard/dashapi (cached) ? github.com/google/syzkaller/docs [no test files] ok github.com/google/syzkaller/executor 3.789s ok github.com/google/syzkaller/pkg/aflow 16.774s ok github.com/google/syzkaller/pkg/aflow/action/actionsyzlang 15.260s ok github.com/google/syzkaller/pkg/aflow/action/crash 14.001s ok github.com/google/syzkaller/pkg/aflow/action/kernel 16.091s ? github.com/google/syzkaller/pkg/aflow/ai [no test files] ? github.com/google/syzkaller/pkg/aflow/backend [no test files] ok github.com/google/syzkaller/pkg/aflow/backend/gemini (cached) ok github.com/google/syzkaller/pkg/aflow/flow 11.655s ? github.com/google/syzkaller/pkg/aflow/flow/assessment [no test files] ok github.com/google/syzkaller/pkg/aflow/flow/common 8.057s ok github.com/google/syzkaller/pkg/aflow/flow/fuzzing 10.213s ok github.com/google/syzkaller/pkg/aflow/flow/patching 11.874s ? github.com/google/syzkaller/pkg/aflow/flow/repro [no test files] ok github.com/google/syzkaller/pkg/aflow/flow/reproc 9.956s ok github.com/google/syzkaller/pkg/aflow/flow/seedgen 9.059s ok github.com/google/syzkaller/pkg/aflow/syzspec 0.612s ? github.com/google/syzkaller/pkg/aflow/tool/checkpatch [no test files] ok github.com/google/syzkaller/pkg/aflow/tool/clangformat 8.239s ok github.com/google/syzkaller/pkg/aflow/tool/codeeditor 8.042s ? github.com/google/syzkaller/pkg/aflow/tool/codeexpert [no test files] ok github.com/google/syzkaller/pkg/aflow/tool/codesearcher 7.310s ok github.com/google/syzkaller/pkg/aflow/tool/gitlog 12.122s ? github.com/google/syzkaller/pkg/aflow/tool/grepper [no test files] ok github.com/google/syzkaller/pkg/aflow/tool/patchdiff 11.897s ok github.com/google/syzkaller/pkg/aflow/tool/syzlang 17.072s ? github.com/google/syzkaller/pkg/aflow/tool/toolkit [no test files] ? github.com/google/syzkaller/pkg/aflow/trajectory [no test files] ok github.com/google/syzkaller/pkg/aflow/trajectory/html (cached) ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 5.028s ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect 246.257s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 15.174s ? github.com/google/syzkaller/pkg/clangtool [no test files] ? github.com/google/syzkaller/pkg/clangtool/tooltest [no test files] ok github.com/google/syzkaller/pkg/codesearch 11.450s ok github.com/google/syzkaller/pkg/compiler 31.664s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 3.507s ok github.com/google/syzkaller/pkg/cover 0.684s ok github.com/google/syzkaller/pkg/cover/backend 17.903s ok github.com/google/syzkaller/pkg/cover/heatmap 0.228s ok github.com/google/syzkaller/pkg/coveragedb (cached) ? github.com/google/syzkaller/pkg/coveragedb/testutil [no test files] ok github.com/google/syzkaller/pkg/covermerger 1.829s ? github.com/google/syzkaller/pkg/covermerger/mocks [no test files] --- FAIL: TestGenerate (79.40s) --- FAIL: TestGenerate/openbsd/amd64 (0.00s) testutil.go:36: seed=1791552340828303317 testutil.go:36: seed=1791552340832635467 --- FAIL: TestGenerate/openbsd/amd64/12 (3.72s) csource_test.go:161: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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; } :322:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 322 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor430234489 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/15 (3.84s) csource_test.go:161: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false CallComments:true LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: // setitimer arguments: [ // which: getitimer_which = 0x0 (8 bytes) // new: ptr[in, itimerval] { // itimerval { // interv: timeval { // sec: intptr = 0x6 (8 bytes) // usec: intptr = 0x4 (8 bytes) // } // value: timeval { // sec: intptr = 0x7f (8 bytes) // usec: intptr = 0x1dd (8 bytes) // } // } // } // old: nil // ] *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: // utimes arguments: [ // filename: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // times: ptr[in, itimerval] { // itimerval { // interv: timeval { // sec: intptr = 0x1 (8 bytes) // usec: intptr = 0x100000001 (8 bytes) // } // value: timeval { // sec: intptr = 0x1 (8 bytes) // usec: intptr = 0x9 (8 bytes) // } // } // } // ] memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: // setitimer arguments: [ // which: getitimer_which = 0x3 (8 bytes) // new: ptr[in, itimerval] { // itimerval { // interv: timeval { // sec: intptr = 0x0 (8 bytes) // usec: intptr = 0x4 (8 bytes) // } // value: timeval { // sec: intptr = 0xffffffffffffffa3 (8 bytes) // usec: intptr = 0x2 (8 bytes) // } // } // } // old: ptr[out, itimerval] { // itimerval { // interv: timeval { // sec: intptr = 0x0 (8 bytes) // usec: intptr = 0x0 (8 bytes) // } // value: timeval { // sec: intptr = 0x0 (8 bytes) // usec: intptr = 0x0 (8 bytes) // } // } // } // ] *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: // rename arguments: [ // old: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // new: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // ] memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: // openat$wsmuxmouse arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 77 73 6d 6f 75 73 65 00} (length 0xd) // } // flags: open_flags = 0x20000 (8 bytes) // mode: const = 0x0 (8 bytes) // ] // returns fd memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: // mknodat arguments: [ // dirfd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // mode: mknod_mode = 0xc000 (8 bytes) // dev: int32 = 0x5 (4 bytes) // ] memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: // bind$inet6 arguments: [ // fd: sock_in6 (resource) // addr: ptr[in, sockaddr_in6] { // sockaddr_in6 { // len: const = 0x1c (1 bytes) // family: const = 0x18 (1 bytes) // port: proc = 0x0 (2 bytes) // flow: int32 = 0x8 (4 bytes) // addr: buffer: {37 21 7b 65 f2 db ae 54 4c 01 a2 b5 4f 7c 25 5f} (length 0x10) // scope: int32 = 0x3 (4 bytes) // } // } // addrlen: len = 0x1c (8 bytes) // ] *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: // ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc01864c2 (8 bytes) // arg: ptr[inout, drm_syncobj_fd_to_handle_arg] { // drm_syncobj_fd_to_handle_arg { // handle: drm_syncobj_handle (resource) // flags: drm_syncobj_fd_to_handle_flags = 0x3 (4 bytes) // fd: fd (resource) // pad: const = 0x0 (4 bytes) // point: int64 = 0xbd3 (8 bytes) // } // } // ] *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: // ioctl$DIOCRSETADDRS arguments: [ // fd: fd_pf (resource) // cmd: const = 0xc4504445 (8 bytes) // arg: ptr[inout, pfioc_table_addrs] { // pfioc_table_addrs { // pfrio_table: pfr_table { // pfrt_anchor: buffer: {2e 2f 66 69 6c 65 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x400) // pfrt_name: buffer: {2e 2f 66 69 6c 65 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20) // pfrt_flags: pfr_table_flags = 0x71 (4 bytes) // pfrt_fback: int8 = 0x8 (1 bytes) // pad: buffer: {00 00 00} (length 0x3) // } // pfrio_buffer: ptr[inout, array[pfr_addr]] { // array[pfr_addr] { // pfr_addr { // pfra_ip: union ipv4_addr { // rand_addr: int32be = 0x1 (4 bytes) // } // pfra_pad: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} (length 0xc) // pfra_ifname: buffer: {2e 2f 66 69 6c 65 30 00 00 00 00 00 00 00 00 00} (length 0x10) // pfra_states: int32 = 0x6 (4 bytes) // pfra_weight: int16 = 0xdc (2 bytes) // pfra_af: pf_af = 0x0 (1 bytes) // pfra_net: int8 = 0x5 (1 bytes) // pfra_not: int8 = 0x5 (1 bytes) // pfra_fback: int8 = 0x0 (1 bytes) // pfra_type: int8 = 0x3 (1 bytes) // pfra_pad2: buffer: {00 00 00 00 00 00 00} (length 0x7) // pad = 0x0 (2 bytes) // } // pfr_addr { // pfra_ip: union ipv4_addr { // local: ipv4_addr_local { // a0: const = 0xac (1 bytes) // a1: const = 0x14 (1 bytes) // a2: proc = 0x0 (1 bytes) // a3: const = 0xaa (1 bytes) // } // } // pfra_pad: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} (length 0xc) // pfra_ifname: buffer: {2e 2f 66 69 6c 65 30 00 00 00 00 00 00 00 00 00} (length 0x10) // pfra_states: int32 = 0x4 (4 bytes) // pfra_weight: int16 = 0x4 (2 bytes) // pfra_af: pf_af = 0x1a (1 bytes) // pfra_net: int8 = 0x2 (1 bytes) // pfra_not: int8 = 0x8 (1 bytes) // pfra_fback: int8 = 0xfe (1 bytes) // pfra_type: int8 = 0x0 (1 bytes) // pfra_pad2: buffer: {00 00 00 00 00 00 00} (length 0x7) // pad = 0x0 (2 bytes) // } // } // } // pfrio_esize: int32 = 0x81 (4 bytes) // pfrio_size: len = 0x2 (4 bytes) // pfrio_size2: int32 = 0x80000000 (4 bytes) // pfrio_nadd: int32 = 0x9 (4 bytes) // pfrio_ndel: int32 = 0x0 (4 bytes) // pfrio_nchange: int32 = 0xfffffff3 (4 bytes) // pfrio_flags: pfr_ioctl_flags = 0x44 (4 bytes) // pfrio_ticket: int32 = 0xcb7 (4 bytes) // } // } // ] memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: // ktrace arguments: [ // tracefile: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 2f 66 69 6c 65 30 00} (length 0xe) // } // ops: ktrace_op_flags = 0x4 (8 bytes) // trpoints: ktrace_trace_flags = 0x20 (8 bytes) // pid: pid (resource) // ] memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); break; case 10: // syz_open_pts arguments: [ // ] // returns fd_tty 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; } :460:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 460 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4220754495 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/7 (3.85s) csource_test.go:161: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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; } 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; } 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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(); loop(); return 0; } :350:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 350 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3146368229 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/9 (4.12s) csource_test.go:161: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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; } :375:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 375 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3088032232 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/8 (4.22s) csource_test.go:161: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:setuid SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) { exit(1); } } closedir(dp); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define CAST static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, WUNTRACED) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_setuid(void) { int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); char pwbuf[1024]; struct passwd *pw, pwres; if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw) exit(1); if (setgroups(0, NULL)) exit(1); if (setgid(pw->pw_gid)) exit(1); if (setuid(pw->pw_uid)) exit(1); loop(); exit(1); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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_setuid(); return 0; } :398:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 398 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3864821980 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/11 (3.39s) csource_test.go:161: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); break; case 10: memset((void*)0x200000000000, 0, 6); memcpy((void*)0x200000000006, "\x02\xe7\xae\x47\x36\x77", 6); *(uint16_t*)0x20000000000c = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 7, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x20000000000e, 0, 4, 12); *(uint16_t*)0x200000000010 = htobe16(0x806); *(uint16_t*)0x200000000012 = htobe16(1); *(uint16_t*)0x200000000014 = htobe16(0x800); *(uint8_t*)0x200000000016 = 6; *(uint8_t*)0x200000000017 = 4; *(uint16_t*)0x200000000018 = htobe16(1); memcpy((void*)0x20000000001a, "\x19\x81\x33\xf7\x3f\xe9", 6); *(uint8_t*)0x200000000020 = 0xac; *(uint8_t*)0x200000000021 = 0x14; *(uint8_t*)0x200000000022 = 0; *(uint8_t*)0x200000000023 = 0xaa; memset((void*)0x200000000024, 170, 5); *(uint8_t*)0x200000000029 = 0xbb; *(uint32_t*)0x20000000002a = htobe32(0xe0000001); syz_emit_ethernet(/*len=*/0x2e, /*packet=*/0x200000000000); break; case 11: syz_extract_tcp_res(/*res=*/0x200000000040, /*seq_inc=*/3, /*ack_inc=*/0xd); 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; } :550:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 550 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor774694670 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/3 (5.31s) csource_test.go:161: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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; } :375:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 375 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2688769920 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/0 (9.61s) csource_test.go:161: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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)) {} *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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; } :223:2: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 223 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3941920138 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/16 (10.63s) csource_test.go:161: 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 CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20 + procid*4); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0 + procid*1; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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; } :377:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 377 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor271037639 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/4 (6.73s) csource_test.go:161: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false CallComments:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: setitimer(0x0, &(0x7f0000000000)={{0x6, 0x4}, {0x7f, 0x1dd}}, 0x0) (fail_nth: 1) utimes(&(0x7f0000000040)='./file0\x00', &(0x7f0000000080)={{0x1, 0x100000001}, {0x1, 0x9}}) (async) setitimer(0x3, &(0x7f00000000c0)={{0x0, 0x4}, {0xffffffffffffffa3, 0x2}}, &(0x7f0000000100)) (rerun: 4) rename(&(0x7f0000000140)='./file0\x00', &(0x7f0000000180)='./file0\x00') r0 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f00000001c0), 0x20000, 0x0) mknodat(r0, &(0x7f0000000200)='./file0\x00', 0xc000, 0x5) bind$inet6(r0, &(0x7f0000000240)={0x1c, 0x18, 0x0, 0x8, "37217b65f2dbae544c01a2b54f7c255f", 0x3}, 0x1c) ioctl$DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE(r0, 0xc01864c2, &(0x7f0000000280)={0x0, 0x3, r0, 0x0, 0xbd3}) ioctl$DIOCRSETADDRS(r0, 0xc4504445, &(0x7f0000000340)={{'./file0\x00', './file0\x00', 0x71, 0x8}, &(0x7f00000002c0)=[{@rand_addr=0x1, '\x00', './file0\x00', 0x6, 0xdc, 0x0, 0x5, 0x5, 0x0, 0x3}, {@local={0xac, 0x14, 0x0}, '\x00', './file0\x00', 0x4, 0x4, 0x1a, 0x2, 0x8, 0xfe}], 0x81, 0x2, 0x80000000, 0x9, 0x0, 0xfffffff3, 0x44, 0xcb7}) ktrace(&(0x7f00000007c0)='./file0/file0\x00', 0x4, 0x20, 0x0) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@empty, @random="02e7ae473677", [{[], {0x8100, 0x7, 0x1}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @random="198133f73fe9", @local={0xac, 0x14, 0x0}, @remote, @multicast1}}}}) syz_extract_tcp_res(&(0x7f0000000040), 0x3, 0xd) syz_open_pts() csource_test.go:162: 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: *(uint64_t*)0x200000000000 = 6; *(uint64_t*)0x200000000008 = 4; *(uint64_t*)0x200000000010 = 0x7f; *(uint64_t*)0x200000000018 = 0x1dd; inject_fault(1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=*/0, /*new=*/0x200000000000, /*old=*/0); break; case 1: memcpy((void*)0x200000000040, "./file0\000", 8); *(uint64_t*)0x200000000080 = 1; *(uint64_t*)0x200000000088 = 0x100000001; *(uint64_t*)0x200000000090 = 1; *(uint64_t*)0x200000000098 = 9; ((intptr_t(*)(intptr_t,intptr_t))CAST(utimes))(/*filename=*/0x200000000040, /*times=*/0x200000000080); break; case 2: *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 4; *(uint64_t*)0x2000000000d0 = 0xffffffffffffffa3; *(uint64_t*)0x2000000000d8 = 2; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(setitimer))(/*which=ITIMER_PROF|ITIMER_VIRTUAL*/3, /*new=*/0x2000000000c0, /*old=*/0x200000000100); } break; case 3: memcpy((void*)0x200000000140, "./file0\000", 8); memcpy((void*)0x200000000180, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t))CAST(rename))(/*old=*/0x200000000140, /*new=*/0x200000000180); break; case 4: memcpy((void*)0x2000000001c0, "/dev/wsmouse\000", 13); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x2000000001c0, /*flags=O_DIRECTORY*/0x20000, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: memcpy((void*)0x200000000200, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ break; case 6: *(uint8_t*)0x200000000240 = 0x1c; *(uint8_t*)0x200000000241 = 0x18; *(uint16_t*)0x200000000242 = htobe16(0x4e20); *(uint32_t*)0x200000000244 = 8; memcpy((void*)0x200000000248, "\x37\x21\x7b\x65\xf2\xdb\xae\x54\x4c\x01\xa2\xb5\x4f\x7c\x25\x5f", 16); *(uint32_t*)0x200000000258 = 3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[0], /*addr=*/0x200000000240, /*addrlen=*/0x1c); break; case 7: *(uint32_t*)0x200000000284 = 3; *(uint32_t*)0x200000000288 = r[0]; *(uint32_t*)0x20000000028c = 0; *(uint64_t*)0x200000000290 = 0xbd3; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc01864c2, /*arg=*/0x200000000280); break; case 8: memcpy((void*)0x200000000340, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 1024); memcpy((void*)0x200000000740, "./file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000000760 = 0x71; *(uint8_t*)0x200000000764 = 8; memset((void*)0x200000000765, 0, 3); *(uint64_t*)0x200000000768 = 0x2000000002c0; *(uint32_t*)0x2000000002c0 = htobe32(1); memset((void*)0x2000000002c4, 0, 12); memcpy((void*)0x2000000002d0, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x2000000002e0 = 6; *(uint16_t*)0x2000000002e4 = 0xdc; *(uint8_t*)0x2000000002e6 = 0; *(uint8_t*)0x2000000002e7 = 5; *(uint8_t*)0x2000000002e8 = 5; *(uint8_t*)0x2000000002e9 = 0; *(uint8_t*)0x2000000002ea = 3; memset((void*)0x2000000002eb, 0, 7); *(uint8_t*)0x2000000002f4 = 0xac; *(uint8_t*)0x2000000002f5 = 0x14; *(uint8_t*)0x2000000002f6 = 0; *(uint8_t*)0x2000000002f7 = 0xaa; memset((void*)0x2000000002f8, 0, 12); memcpy((void*)0x200000000304, "./file0\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000314 = 4; *(uint16_t*)0x200000000318 = 4; *(uint8_t*)0x20000000031a = 0x1a; *(uint8_t*)0x20000000031b = 2; *(uint8_t*)0x20000000031c = 8; *(uint8_t*)0x20000000031d = 0xfe; *(uint8_t*)0x20000000031e = 0; memset((void*)0x20000000031f, 0, 7); *(uint32_t*)0x200000000770 = 0x81; *(uint32_t*)0x200000000774 = 2; *(uint32_t*)0x200000000778 = 0x80000000; *(uint32_t*)0x20000000077c = 9; *(uint32_t*)0x200000000780 = 0; *(uint32_t*)0x200000000784 = 0xfffffff3; *(uint32_t*)0x200000000788 = 0x44; *(uint32_t*)0x20000000078c = 0xcb7; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc4504445, /*arg=*/0x200000000340); break; case 9: memcpy((void*)0x2000000007c0, "./file0/file0\000", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(ktrace))(/*tracefile=*/0x2000000007c0, /*ops=KTRFLAG_DESCEND*/4, /*trpoints=KTRFAC_PSIG*/0x20, /*pid=*/0); 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; } :375:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] 375 | NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x200000000200, /*mode=S_IFSOCK*/0xc000, /*dev=*/5)); /* major = 0, minor = 5 */ | ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2165977012 -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-format-overflow -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/5 (11.43s) csource_test.go:159: --- FAIL: TestGenerate/openbsd/amd64/14 (11.54s) csource_test.go:159: --- FAIL: TestGenerate/openbsd/amd64/10 (13.94s) csource_test.go:159: --- FAIL: TestGenerate/openbsd/amd64/6 (10.62s) csource_test.go:159: --- FAIL: TestGenerate/openbsd/amd64/1 (6.12s) csource_test.go:159: --- FAIL: TestGenerate/openbsd/amd64/2 (9.94s) csource_test.go:159: FAIL FAIL github.com/google/syzkaller/pkg/csource 118.411s ok github.com/google/syzkaller/pkg/db 12.017s ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/declextract [no test files] ok github.com/google/syzkaller/pkg/dungeon (cached) ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore (cached) ok github.com/google/syzkaller/pkg/email/sender (cached) ok github.com/google/syzkaller/pkg/execbackend 18.420s ok github.com/google/syzkaller/pkg/flatrpc (cached) ok github.com/google/syzkaller/pkg/fuzzer 19.439s ok github.com/google/syzkaller/pkg/fuzzer/queue 0.593s ok github.com/google/syzkaller/pkg/gce (cached) ? github.com/google/syzkaller/pkg/gcpsecret [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/gcs/mocks [no test files] ok github.com/google/syzkaller/pkg/gerrit (cached) ok github.com/google/syzkaller/pkg/gvisor (cached) ok github.com/google/syzkaller/pkg/hash (cached) ok github.com/google/syzkaller/pkg/html (cached) ok github.com/google/syzkaller/pkg/html/pages (cached) ok github.com/google/syzkaller/pkg/html/urlutil (cached) ? github.com/google/syzkaller/pkg/ifaceprobe [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/ifuzz/arm64 (cached) ? github.com/google/syzkaller/pkg/ifuzz/arm64/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/arm64/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ok github.com/google/syzkaller/pkg/ifuzz/riscv64 (cached) ? github.com/google/syzkaller/pkg/ifuzz/riscv64/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/riscv64/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 12.416s ok github.com/google/syzkaller/pkg/instance 16.160s ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/pkg/kconfig (cached) ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/kfuzztest 0.506s ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/lore-relay (cached) ok github.com/google/syzkaller/pkg/manager 21.238s ok github.com/google/syzkaller/pkg/manager/diff 18.060s ok github.com/google/syzkaller/pkg/mgrconfig 16.997s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 35.952s ok github.com/google/syzkaller/pkg/report/crash (cached) ok github.com/google/syzkaller/pkg/repro 19.340s ok github.com/google/syzkaller/pkg/rpcserver 13.850s ? 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 86.997s ok github.com/google/syzkaller/pkg/serializer (cached) ok github.com/google/syzkaller/pkg/signal (cached) ok github.com/google/syzkaller/pkg/spanner (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 (cached) ? github.com/google/syzkaller/pkg/testutil [no test files] ok github.com/google/syzkaller/pkg/tool (cached) ? github.com/google/syzkaller/pkg/updater [no test files] ok github.com/google/syzkaller/pkg/validator (cached) ok github.com/google/syzkaller/pkg/vcs (cached) ok github.com/google/syzkaller/pkg/vminfo 34.462s ok github.com/google/syzkaller/pkg/vminfo/features (cached) ok github.com/google/syzkaller/prog 145.327s ok github.com/google/syzkaller/prog/test 5.765s ? 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 6.457s ok github.com/google/syzkaller/sys/netbsd 1.018s ok github.com/google/syzkaller/sys/openbsd 2.111s ? 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-agent/agent 43.119s ? github.com/google/syzkaller/syz-agent/lore-relay [no test files] ok github.com/google/syzkaller/syz-ci 102.715s ok github.com/google/syzkaller/syz-cluster/controller 4.929s ok github.com/google/syzkaller/syz-cluster/dashboard 3.180s ok github.com/google/syzkaller/syz-cluster/email-reporter 1.661s ok github.com/google/syzkaller/syz-cluster/pkg/api 1.268s ok github.com/google/syzkaller/syz-cluster/pkg/app 3.563s ok github.com/google/syzkaller/syz-cluster/pkg/blob (cached) ok github.com/google/syzkaller/syz-cluster/pkg/controller 3.582s ok github.com/google/syzkaller/syz-cluster/pkg/db 3.336s ? github.com/google/syzkaller/syz-cluster/pkg/emailclient [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/fuzzconfig 9.957s ok github.com/google/syzkaller/syz-cluster/pkg/report 2.905s ok github.com/google/syzkaller/syz-cluster/pkg/reporter 3.254s ok github.com/google/syzkaller/syz-cluster/pkg/retest 28.381s ? github.com/google/syzkaller/syz-cluster/pkg/service [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/stats 0.599s ok github.com/google/syzkaller/syz-cluster/pkg/triage 39.713s ? github.com/google/syzkaller/syz-cluster/pkg/workflow [no test files] ? github.com/google/syzkaller/syz-cluster/pkg/workspace [no test files] ? github.com/google/syzkaller/syz-cluster/reporter-server [no test files] ok github.com/google/syzkaller/syz-cluster/series-tracker 1.381s ? github.com/google/syzkaller/syz-cluster/tools/db-mgmt [no test files] ? github.com/google/syzkaller/syz-cluster/tools/send-test-email [no test files] ? github.com/google/syzkaller/syz-cluster/workflow/boot [no test files] ? github.com/google/syzkaller/syz-cluster/workflow/build [no test files] ok github.com/google/syzkaller/syz-cluster/workflow/fuzz 23.309s ? github.com/google/syzkaller/syz-cluster/workflow/retest [no test files] ? github.com/google/syzkaller/syz-cluster/workflow/triage [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 15.041s ? github.com/google/syzkaller/syz-verifier [no test files] ? github.com/google/syzkaller/tools/arm64 [no test files] ? github.com/google/syzkaller/tools/clang/codesearch [no test files] ? github.com/google/syzkaller/tools/clang/declextract [no test files] ? github.com/google/syzkaller/tools/kfuzztest-gen [no test files] ok github.com/google/syzkaller/tools/syz-aflow 22.292s ? github.com/google/syzkaller/tools/syz-base-commit [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-codesearch [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 4.544s ? github.com/google/syzkaller/tools/syz-db-export [no test files] ok github.com/google/syzkaller/tools/syz-declextract 3.937s ? 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-fmt [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 15.182s 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 16.862s ? 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 0.912s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 4.553s ? github.com/google/syzkaller/tools/syz-tty [no test files] ok github.com/google/syzkaller/tools/syz-uncovered-batch 1.602s ? 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 27.746s ok github.com/google/syzkaller/vm/adb 9.728s ? 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 8.492s ok github.com/google/syzkaller/vm/proxyapp 10.022s ? github.com/google/syzkaller/vm/proxyapp/mocks [no test files] ? github.com/google/syzkaller/vm/proxyapp/proxyrpc [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ? github.com/google/syzkaller/vm/starnix [no test files] ? github.com/google/syzkaller/vm/virtualbox [no test files] ok github.com/google/syzkaller/vm/vmimpl 6.659s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL