ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 1.490s ok github.com/google/syzkaller/pkg/ast 3.002s ok github.com/google/syzkaller/pkg/bisect 49.790s ok github.com/google/syzkaller/pkg/build 0.136s ? github.com/google/syzkaller/pkg/cmdprof [no test files] ok github.com/google/syzkaller/pkg/compiler 10.813s ok github.com/google/syzkaller/pkg/config (cached) ? github.com/google/syzkaller/pkg/cover [no test files] --- FAIL: TestGenerate (5.56s) --- FAIL: TestGenerate/freebsd/386 (1.14s) csource_test.go:67: seed=1606994515487193467 --- FAIL: TestGenerate/freebsd/386/14 (1.08s) csource_test.go:123: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:2 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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; int collide = 0; again: 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 (collide && (call % 2) == 0) break; event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :367:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor421330499 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/0 (1.23s) csource_test.go:123: opts: {Threaded:false Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } #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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_one(void) { intptr_t res = 0; res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :202:10: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor377423558 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/8 (1.34s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:setuid Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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); } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_setuid(); return 0; } :378:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor917644264 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/13 (1.54s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:true} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { fprintf(stderr, "### start\n"); 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; res = syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); res = syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: *(uint32_t*)0x10000300 = 0xc; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; res = syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); (void)res; break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); res = -1; errno = EFAULT; res = syz_execute_func(0x10000100); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; case 12: (void)res; break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :362:17: error: use of undeclared identifier 'SYS_freebsd12_shm_open' res = syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor445726042 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/9 (1.47s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static 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); if (rmdir(dir)) exit(1); } 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)))) static int tunfd = -1; #define MAX_TUN 4 #define TUN_IFACE "tap%d" #define TUN_DEVICE "/dev/tap%d" #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 REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" 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[sizeof(TUN_DEVICE)]; snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id); char tun_iface[sizeof(TUN_IFACE)]; snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id); execute_command(0, "ifconfig %s destroy", tun_device); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); if ((tunfd < 0) && (errno == ENOENT)) { execute_command(0, "kldload -q if_tap"); 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 = 240; 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 ether %s", tun_iface, local_mac); char local_ipv4[sizeof(LOCAL_IPV4)]; 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[sizeof(REMOTE_IPV4)]; 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[sizeof(LOCAL_IPV6)]; 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[sizeof(REMOTE_IPV6)]; 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() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); syz_emit_ethernet(0xd9, 0x10000000); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: syz_extract_tcp_res(0x10000140, 9, 0x58e); break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :527:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor913318641 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/10 (1.58s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:false HandleSegv:false Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); do_sandbox_none(); return 0; } :302:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor230190492 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/11 (1.76s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:true Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (sig == SIGBUS) { valid = 1; } if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) ({ int ok = 1; __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); if (_setjmp(segv_env) == 0) { __VA_ARGS__; } else ok = 0; __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); ok; }) 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); if (rmdir(dir)) exit(1); } 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { NONFAILING(r[0] = *(uint32_t*)0x10000000); NONFAILING(r[1] = *(uint32_t*)0x10000004); } break; case 1: NONFAILING(*(uint32_t*)0x10000040 = 0); NONFAILING(*(uint32_t*)0x10000044 = 5); NONFAILING(*(uint32_t*)0x10000080 = 8); res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) NONFAILING(r[2] = *(uint32_t*)0x10000040); break; case 2: NONFAILING(*(uint8_t*)0x100000c0 = 1); syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: NONFAILING(*(uint16_t*)0x10000100 = 0x8001); NONFAILING(*(uint16_t*)0x10000102 = 0xf7); NONFAILING(*(uint16_t*)0x10000104 = 0x20); NONFAILING(*(uint32_t*)0x10000108 = 0x930); NONFAILING(*(uint32_t*)0x1000010c = 4); NONFAILING(*(uint32_t*)0x10000110 = 0x7fffffff); NONFAILING(*(uint32_t*)0x10000114 = 3); NONFAILING(*(uint32_t*)0x10000118 = 0x7ff); NONFAILING(*(uint32_t*)0x1000011c = r[2]); NONFAILING(*(uint32_t*)0x10000140 = 0x20); res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) NONFAILING(r[3] = *(uint32_t*)0x1000011c); break; case 4: NONFAILING(*(uint32_t*)0x10000180 = r[3]); NONFAILING(*(uint32_t*)0x10000184 = 0xfffffffb); NONFAILING(*(uint32_t*)0x100001c0 = 8); res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) NONFAILING(r[4] = *(uint32_t*)0x10000180); break; case 5: NONFAILING(*(uint32_t*)0x10000240 = 4); syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: NONFAILING(memcpy((void*)0x10000280, "./file0\000", 8)); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: NONFAILING(*(uint32_t*)0x10000300 = 0xc); syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: NONFAILING(*(uint32_t*)0x10000340 = r[4]); NONFAILING(*(uint32_t*)0x10000344 = 0x90); NONFAILING(memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144)); NONFAILING(*(uint32_t*)0x10000400 = 0x98); res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) NONFAILING(r[5] = *(uint32_t*)0x10000340); break; case 9: NONFAILING(*(uint32_t*)0x10000440 = r[5]); NONFAILING(*(uint32_t*)0x10000444 = 0x380000); syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: NONFAILING(memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6)); NONFAILING(*(uint8_t*)0x10000006 = 0xaa); NONFAILING(*(uint8_t*)0x10000007 = 0xaa); NONFAILING(*(uint8_t*)0x10000008 = 0xaa); NONFAILING(*(uint8_t*)0x10000009 = 0xaa); NONFAILING(*(uint8_t*)0x1000000a = 0xaa); NONFAILING(*(uint8_t*)0x1000000b = 0xbb); NONFAILING(*(uint16_t*)0x1000000c = htobe16(0x88a8)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12)); NONFAILING(*(uint16_t*)0x10000010 = htobe16(0x8100)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12)); NONFAILING(*(uint16_t*)0x10000014 = htobe16(0x852b)); NONFAILING(memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195)); break; case 11: NONFAILING(memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59)); NONFAILING(syz_execute_func(0x10000100)); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; } :387:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor184158283 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/4 (1.35s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:10 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :355:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor012067118 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/7 (1.55s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox: Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } 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)))) static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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) { 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); loop(); return 0; } :326:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor160225424 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/12 (2.10s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: freebsd10_pipe(&(0x7f0000000000)={0xffffffffffffffff, 0xffffffffffffffff}) getsockopt$inet6_sctp_SCTP_RECONFIG_SUPPORTED(r1, 0x84, 0x29, &(0x7f0000000040)={0x0, 0x5}, &(0x7f0000000080)=0x8) setsockopt$inet_sctp_SCTP_AUTH_CHUNK(r1, 0x84, 0x12, &(0x7f00000000c0)={0x1}, 0x1) getsockopt$inet6_sctp_SCTP_DEFAULT_SEND_PARAM(r1, 0x84, 0xb, &(0x7f0000000100)={0x8001, 0xf7, 0x20, 0x930, 0x4, 0x7fffffff, 0x3, 0x7ff, r2}, &(0x7f0000000140)=0x20) getsockopt$inet6_sctp_SCTP_ENABLE_STREAM_RESET(r0, 0x84, 0x900, &(0x7f0000000180)={r3, 0xfffffffb}, &(0x7f00000001c0)=0x8) getsockopt$inet6_sctp_SCTP_AUTOCLOSE(r1, 0x84, 0x5, &(0x7f0000000200), &(0x7f0000000240)=0x4) freebsd12_shm_open(&(0x7f0000000280)='./file0\x00', 0x400, 0x42) getsockopt$inet_mreqn(r1, 0x0, 0xc, &(0x7f00000002c0)={@loopback, @broadcast}, &(0x7f0000000300)=0xc) getsockopt$inet_sctp_SCTP_PEER_AUTH_CHUNKS(r1, 0x84, 0x102, &(0x7f0000000340)={r4, 0x90, "1820b3470f5b5c91a74b004ca2c2fbef6293d8aba0f61ab028b364e24794a6142cec76a406861585404606bf6bd7a0a1e3fd6622cd20e821863c1f0d7db327369bb5eb4d9623656871cbecd2f5aa12ceca53b82b57a621e33840a09eba2d0c287f6a1ad62719f080cdb4667b37a750f8beda7750356e5c2ffb7aed86b8133c80d160d3d3f42252bb2beec7a0ea39a19f"}, &(0x7f0000000400)=0x98) setsockopt$inet_sctp_SCTP_MAX_BURST(r0, 0x84, 0x19, &(0x7f0000000440)={r5, 0x380000}, 0x8) syz_emit_ethernet(0xd9, &(0x7f0000000000)={@random="6ccf3624899d", @remote, [{[{0x88a8, 0x4, 0x0, 0x1}], {0x8100, 0x0, 0x1}}], {@generic={0x852b, "593d08a759c8cdfa70f5735d21bed023bf18feddde86836b615ea8fde54cd4ff7ff87ce29ba318b814fa028f2888d7d60de396ff93e94444d34afbf1ab8b6dd4e34d9ab137b8e3757c85168830a6315536a47f487f64a6ad70ac010bfb6256c4477d6ba73a8a82322268e4eb851e9b456163feafe7f6330f6559e82d3a33ec5f2b910ebfb96b96ce2584a9da6f5ccc203d6883ed341a060a71b855b549a5ce29853c41e6eab3cec7f476d5a9ae20ff00bfabcc99c142c4483a3d9d0ce7f15b76c3148e"}}}) syz_execute_func(&(0x7f0000000100)="c4e1b5585d00c4c3414a5dbbc0c4e1ff703bf9c4c1057506c4c1615cca67c8f3ff1ac4e17014e76667e500f080803747775b0cf30faea75c000000") syz_extract_tcp_res(&(0x7f0000000140), 0x9, 0x58e) csource_test.go:124: 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 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); if (rmdir(dir)) exit(1); } 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)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &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 long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); 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); event_timedwait(&th->done, 45); 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_freebsd10_pipe, 0x10000000); if (res != -1) { r[0] = *(uint32_t*)0x10000000; r[1] = *(uint32_t*)0x10000004; } break; case 1: *(uint32_t*)0x10000040 = 0; *(uint32_t*)0x10000044 = 5; *(uint32_t*)0x10000080 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x29, 0x10000040, 0x10000080); if (res != -1) r[2] = *(uint32_t*)0x10000040; break; case 2: *(uint8_t*)0x100000c0 = 1; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x12, 0x100000c0, 1); break; case 3: *(uint16_t*)0x10000100 = 0x8001; *(uint16_t*)0x10000102 = 0xf7; *(uint16_t*)0x10000104 = 0x20; *(uint32_t*)0x10000108 = 0x930; *(uint32_t*)0x1000010c = 4; *(uint32_t*)0x10000110 = 0x7fffffff; *(uint32_t*)0x10000114 = 3; *(uint32_t*)0x10000118 = 0x7ff; *(uint32_t*)0x1000011c = r[2]; *(uint32_t*)0x10000140 = 0x20; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0xb, 0x10000100, 0x10000140); if (res != -1) r[3] = *(uint32_t*)0x1000011c; break; case 4: *(uint32_t*)0x10000180 = r[3]; *(uint32_t*)0x10000184 = 0xfffffffb; *(uint32_t*)0x100001c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x900, 0x10000180, 0x100001c0); if (res != -1) r[4] = *(uint32_t*)0x10000180; break; case 5: *(uint32_t*)0x10000240 = 4; syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 5, 0x10000200, 0x10000240); break; case 6: memcpy((void*)0x10000280, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); break; case 7: *(uint32_t*)0x10000300 = 0xc; syscall(SYS_getsockopt, (intptr_t)r[1], 0, 0xc, 0x100002c0, 0x10000300); break; case 8: *(uint32_t*)0x10000340 = r[4]; *(uint32_t*)0x10000344 = 0x90; memcpy((void*)0x10000348, "\x18\x20\xb3\x47\x0f\x5b\x5c\x91\xa7\x4b\x00\x4c\xa2\xc2\xfb\xef\x62\x93\xd8\xab\xa0\xf6\x1a\xb0\x28\xb3\x64\xe2\x47\x94\xa6\x14\x2c\xec\x76\xa4\x06\x86\x15\x85\x40\x46\x06\xbf\x6b\xd7\xa0\xa1\xe3\xfd\x66\x22\xcd\x20\xe8\x21\x86\x3c\x1f\x0d\x7d\xb3\x27\x36\x9b\xb5\xeb\x4d\x96\x23\x65\x68\x71\xcb\xec\xd2\xf5\xaa\x12\xce\xca\x53\xb8\x2b\x57\xa6\x21\xe3\x38\x40\xa0\x9e\xba\x2d\x0c\x28\x7f\x6a\x1a\xd6\x27\x19\xf0\x80\xcd\xb4\x66\x7b\x37\xa7\x50\xf8\xbe\xda\x77\x50\x35\x6e\x5c\x2f\xfb\x7a\xed\x86\xb8\x13\x3c\x80\xd1\x60\xd3\xd3\xf4\x22\x52\xbb\x2b\xee\xc7\xa0\xea\x39\xa1\x9f", 144); *(uint32_t*)0x10000400 = 0x98; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x102, 0x10000340, 0x10000400); if (res != -1) r[5] = *(uint32_t*)0x10000340; break; case 9: *(uint32_t*)0x10000440 = r[5]; *(uint32_t*)0x10000444 = 0x380000; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x19, 0x10000440, 8); break; case 10: memcpy((void*)0x10000000, "\x6c\xcf\x36\x24\x89\x9d", 6); *(uint8_t*)0x10000006 = 0xaa; *(uint8_t*)0x10000007 = 0xaa; *(uint8_t*)0x10000008 = 0xaa; *(uint8_t*)0x10000009 = 0xaa; *(uint8_t*)0x1000000a = 0xaa; *(uint8_t*)0x1000000b = 0xbb; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 1, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 1, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x852b); memcpy((void*)0x10000016, "\x59\x3d\x08\xa7\x59\xc8\xcd\xfa\x70\xf5\x73\x5d\x21\xbe\xd0\x23\xbf\x18\xfe\xdd\xde\x86\x83\x6b\x61\x5e\xa8\xfd\xe5\x4c\xd4\xff\x7f\xf8\x7c\xe2\x9b\xa3\x18\xb8\x14\xfa\x02\x8f\x28\x88\xd7\xd6\x0d\xe3\x96\xff\x93\xe9\x44\x44\xd3\x4a\xfb\xf1\xab\x8b\x6d\xd4\xe3\x4d\x9a\xb1\x37\xb8\xe3\x75\x7c\x85\x16\x88\x30\xa6\x31\x55\x36\xa4\x7f\x48\x7f\x64\xa6\xad\x70\xac\x01\x0b\xfb\x62\x56\xc4\x47\x7d\x6b\xa7\x3a\x8a\x82\x32\x22\x68\xe4\xeb\x85\x1e\x9b\x45\x61\x63\xfe\xaf\xe7\xf6\x33\x0f\x65\x59\xe8\x2d\x3a\x33\xec\x5f\x2b\x91\x0e\xbf\xb9\x6b\x96\xce\x25\x84\xa9\xda\x6f\x5c\xcc\x20\x3d\x68\x83\xed\x34\x1a\x06\x0a\x71\xb8\x55\xb5\x49\xa5\xce\x29\x85\x3c\x41\xe6\xea\xb3\xce\xc7\xf4\x76\xd5\xa9\xae\x20\xff\x00\xbf\xab\xcc\x99\xc1\x42\xc4\x48\x3a\x3d\x9d\x0c\xe7\xf1\x5b\x76\xc3\x14\x8e", 195); break; case 11: memcpy((void*)0x10000100, "\xc4\xe1\xb5\x58\x5d\x00\xc4\xc3\x41\x4a\x5d\xbb\xc0\xc4\xe1\xff\x70\x3b\xf9\xc4\xc1\x05\x75\x06\xc4\xc1\x61\x5c\xca\x67\xc8\xf3\xff\x1a\xc4\xe1\x70\x14\xe7\x66\x67\xe5\x00\xf0\x80\x80\x37\x47\x77\x5b\x0c\xf3\x0f\xae\xa7\x5c\x00\x00\x00", 59); syz_execute_func(0x10000100); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :357:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000280, 0x400, 0x42); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor514484917 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/6 (1.40s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/3 (0.95s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/2 (1.28s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/5 (1.41s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/1 (0.99s) csource_test.go:121: FAIL FAIL github.com/google/syzkaller/pkg/csource 13.529s ok github.com/google/syzkaller/pkg/db (cached) ok github.com/google/syzkaller/pkg/email (cached) ? github.com/google/syzkaller/pkg/gce [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ok github.com/google/syzkaller/pkg/host 1.462s ? github.com/google/syzkaller/pkg/html [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ok github.com/google/syzkaller/pkg/instance 1.343s ok github.com/google/syzkaller/pkg/ipc 5.122s ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/pkg/kconfig (cached) ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig 0.091s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 3.411s ok github.com/google/syzkaller/pkg/repro 0.149s ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 55.994s ok github.com/google/syzkaller/pkg/serializer (cached) ? github.com/google/syzkaller/pkg/signal [no test files] ok github.com/google/syzkaller/pkg/symbolizer 0.516s ok github.com/google/syzkaller/pkg/vcs 11.207s ok github.com/google/syzkaller/prog (cached) ok github.com/google/syzkaller/prog/test (cached) ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ok github.com/google/syzkaller/sys/linux (cached) ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ok github.com/google/syzkaller/sys/openbsd (cached) ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ok github.com/google/syzkaller/syz-ci 0.257s ok github.com/google/syzkaller/syz-fuzzer 0.672s ok github.com/google/syzkaller/syz-hub 0.058s ok github.com/google/syzkaller/syz-hub/state 0.094s ok github.com/google/syzkaller/syz-manager 0.146s ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [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-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ? github.com/google/syzkaller/tools/syz-kconf [no test files] ok github.com/google/syzkaller/tools/syz-linter 1.968s ? 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-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/parser (cached) ok github.com/google/syzkaller/tools/syz-trace2syz/proggen (cached) ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ok github.com/google/syzkaller/vm 9.142s ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? 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 0.107s ? github.com/google/syzkaller/vm/kvm [no test files] ? github.com/google/syzkaller/vm/odroid [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ok github.com/google/syzkaller/vm/vmimpl 0.174s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL