ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 1.295s ok github.com/google/syzkaller/pkg/ast 3.463s ok github.com/google/syzkaller/pkg/bisect 57.138s ok github.com/google/syzkaller/pkg/build 0.273s ok github.com/google/syzkaller/pkg/compiler 13.937s ? github.com/google/syzkaller/pkg/config [no test files] ok github.com/google/syzkaller/pkg/cover 0.141s ok github.com/google/syzkaller/pkg/cover/backend 0.048s --- FAIL: TestGenerate (6.22s) --- FAIL: TestGenerate/freebsd/386 (0.47s) csource_test.go:52: seed=1620758557200993268 --- FAIL: TestGenerate/freebsd/386/1 (0.99s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :409:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor415239233 -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 (0.39s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); loop(); return 0; } :382:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor068205595 -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.10s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_setuid(); return 0; } :432:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor270204076 -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 (0.65s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:10 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 500); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 15000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :409:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor435420350 -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 (0.89s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:4 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21 + procid*4); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0 + procid*1; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0 + procid*1; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0 + procid*1; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0 + procid*1; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0 + procid*1; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0 + procid*1; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0 + procid*1; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :411:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor765223173 -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/3 (0.95s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:false RepeatTimes:0 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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 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 thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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 loop(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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :328:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor482722514 -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 (0.94s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:10 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :409:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor218607999 -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/5 (1.00s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :409:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor643305632 -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/2 (1.04s) csource_test.go:108: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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; 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, 50); 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 < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); break; case 9: syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); syz_execute_func(0x10000180); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :417:11: error: use of undeclared identifier 'SYS_freebsd12_closefrom' syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor660599252 -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/14 (0.97s) csource_test.go:108: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 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 IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:true} program: getsockopt$inet6_sctp_SCTP_DEFAULT_SNDINFO(0xffffffffffffffff, 0x84, 0x21, &(0x7f0000000000)={0x5, 0x110, 0x3, 0x51d1, 0x0}, &(0x7f0000000040)=0x10) setsockopt$inet6_sctp_SCTP_AUTH_DELETE_KEY(0xffffffffffffffff, 0x84, 0x16, &(0x7f0000000080)={r0, 0x7}, 0x8) r1 = dup2(0xffffffffffffffff, 0xffffffffffffff9c) getsockopt$inet_sctp_SCTP_ASSOCINFO(r1, 0x84, 0x2, &(0x7f00000000c0)={r0, 0x8, 0x9, 0x10001, 0x2, 0x100}, &(0x7f0000000100)=0x14) getsockopt$inet6_sctp_SCTP_PRIMARY_ADDR(r1, 0x84, 0x7, &(0x7f0000000140)={@in={{0x10, 0x2, 0x1, @local={0xac, 0x14, 0x0}}}, r2}, &(0x7f0000000200)=0x84) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r1, 0x84, 0x8004, &(0x7f0000000280)={r2, &(0x7f0000000240)=[@in6={0x1c, 0x1c, 0xffffffffffffffff, 0x0, @ipv4={""/10, ""/2, @rand_addr}}, @in={0x10, 0x2, 0xffffffffffffffff, @broadcast}]}, &(0x7f00000002c0)=0x8) setsockopt$inet6_sctp_SCTP_DEFAULT_PRINFO(r1, 0x84, 0x22, &(0x7f0000000300)={0x1, 0xfffffffc, r4}, 0xc) r5 = openat(r1, &(0x7f0000000340)='./file0\x00', 0x200, 0x40) setsockopt$inet6_sctp_SCTP_DELAYED_SACK(r5, 0x84, 0xf, &(0x7f0000000380)={r3, 0x9, 0x5}, 0xc) freebsd12_closefrom(r5) syz_emit_ethernet(0x17e, &(0x7f0000000000)={@local, @random="3aed67f62007", [], {@ipv4={0x800, {{0x2a, 0x4, 0x0, 0x2, 0x170, 0x67, 0x0, 0x5, 0x18, 0x0, @multicast1, @empty, {[@timestamp={0x44, 0x18, 0x52, 0x1, 0x9, [{[@local={0xac, 0x14, 0x0}], 0x7fff}, {[@loopback], 0x3}, {[], 0xff}]}, @rr={0x7, 0x7, 0x1f, [@remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0xf, 0x4, [@rand_addr=0xfffffffc, @loopback, @empty]}, @noop, @lsrr={0x83, 0x17, 0x8, [@empty, @local={0xac, 0x14, 0x0}, @rand_addr=0x2, @multicast1, @multicast1]}, @ssrr={0x89, 0x13, 0xff, [@local={0xac, 0x14, 0x0}, @multicast2, @multicast1, @multicast1]}, @generic={0x4b, 0xb, "4f2bbb400d41ca92c7"}, @ra={0x94, 0x6, 0x1ff}, @rr={0x7, 0x27, 0x81, [@broadcast, @loopback, @multicast1, @empty, @local={0xac, 0x14, 0x0}, @remote={0xac, 0x14, 0x0}, @broadcast, @multicast1, @empty]}]}}, @generic="5fea16ab24fdf4399dba4baddf2a3045ffbf4a7cead001987b825cce718973e7da1f030820b44e9058c7d5e387cc66e07e34fa0942bf666ca2eaf163cf1992f6b70427912f08287c77b270186c32896b1607fe312e0d39210e69aabd6c0e0869b6e1504dcf72f8a4ad5db8e6befbf28fb2c52332dd82f6491ecd14668d3e44884465a9ae2d00e33b6b18fe5fb586005667c40b9b866948df469d4b4fca166b26d908e1eda7fc09fb9515800987c9307fb7f91b74b466091e6bf55a009ea0e37631efc96d04783d2e"}}}}) syz_execute_func(&(0x7f0000000180)="c4c2c5a85e02c4e17c29cdc4c1e012c2c4c1fee60c76f30f01a8000000000f3accbef1ffffffe2c4c1e85f8535070000c091ffefffff02c4e1d912920c000000c4e24d2bf4") syz_extract_tcp_res(&(0x7f0000000200), 0xffff, 0x6) csource_test.go:109: 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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) { continue; } kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[6] = {0x0, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint16_t*)0x10000000 = 5; *(uint16_t*)0x10000002 = 0x110; *(uint32_t*)0x10000004 = 3; *(uint32_t*)0x10000008 = 0x51d1; *(uint32_t*)0x1000000c = 0; *(uint32_t*)0x10000040 = 0x10; res = syscall(SYS_getsockopt, -1, 0x84, 0x21, 0x10000000, 0x10000040); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = *(uint32_t*)0x1000000c; break; case 1: *(uint32_t*)0x10000080 = r[0]; *(uint16_t*)0x10000084 = 7; res = syscall(SYS_setsockopt, -1, 0x84, 0x16, 0x10000080, 8); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: res = syscall(SYS_dup2, -1, 0xffffff9c); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x100000c0 = r[0]; *(uint32_t*)0x100000c4 = 8; *(uint32_t*)0x100000c8 = 9; *(uint32_t*)0x100000cc = 0x10001; *(uint16_t*)0x100000d0 = 2; *(uint16_t*)0x100000d2 = 0x100; *(uint32_t*)0x10000100 = 0x14; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 2, 0x100000c0, 0x10000100); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[2] = *(uint32_t*)0x100000c0; break; case 4: *(uint8_t*)0x10000140 = 0x10; *(uint8_t*)0x10000141 = 2; *(uint16_t*)0x10000142 = htobe16(0x4e21); *(uint8_t*)0x10000144 = 0xac; *(uint8_t*)0x10000145 = 0x14; *(uint8_t*)0x10000146 = 0; *(uint8_t*)0x10000147 = 0xaa; memset((void*)0x10000148, 0, 8); memset((void*)0x10000150, 0, 112); *(uint32_t*)0x100001c0 = r[2]; *(uint32_t*)0x10000200 = 0x84; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 7, 0x10000140, 0x10000200); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[3] = *(uint32_t*)0x100001c0; break; case 5: *(uint32_t*)0x10000280 = r[2]; *(uint32_t*)0x10000284 = 0x10000240; *(uint32_t*)0x100002c0 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[1], 0x84, 0x8004, 0x10000280, 0x100002c0); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[4] = *(uint32_t*)0x10000280; break; case 6: *(uint16_t*)0x10000300 = 1; *(uint32_t*)0x10000304 = 0xfffffffc; *(uint32_t*)0x10000308 = r[4]; res = syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x22, 0x10000300, 0xc); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: memcpy((void*)0x10000340, "./file0\000", 8); res = syscall(SYS_openat, (intptr_t)r[1], 0x10000340, 0x200, 0x40); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[5] = res; break; case 8: *(uint32_t*)0x10000380 = r[3]; *(uint32_t*)0x10000384 = 9; *(uint32_t*)0x10000388 = 5; res = syscall(SYS_setsockopt, (intptr_t)r[5], 0x84, 0xf, 0x10000380, 0xc); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: res = syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memset((void*)0x10000000, 170, 5); *(uint8_t*)0x10000005 = 0xaa; memcpy((void*)0x10000006, "\x3a\xed\x67\xf6\x20\x07", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x170); *(uint16_t*)0x10000012 = htobe16(0x67); *(uint16_t*)0x10000014 = htobe16(0); *(uint8_t*)0x10000016 = 5; *(uint8_t*)0x10000017 = 0x18; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000001); *(uint32_t*)0x1000001e = htobe32(0); *(uint8_t*)0x10000022 = 0x44; *(uint8_t*)0x10000023 = 0x18; *(uint8_t*)0x10000024 = 0x52; STORE_BY_BITMASK(uint8_t, , 0x10000025, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x10000025, 9, 4, 4); *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; *(uint32_t*)0x1000002a = htobe32(0x7fff); *(uint32_t*)0x1000002e = htobe32(0x7f000001); *(uint32_t*)0x10000032 = htobe32(3); *(uint32_t*)0x10000036 = htobe32(0xff); *(uint8_t*)0x1000003a = 7; *(uint8_t*)0x1000003b = 7; *(uint8_t*)0x1000003c = 0x1f; *(uint8_t*)0x1000003d = 0xac; *(uint8_t*)0x1000003e = 0x14; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0xbb; *(uint8_t*)0x10000041 = 0x89; *(uint8_t*)0x10000042 = 0xf; *(uint8_t*)0x10000043 = 4; *(uint32_t*)0x10000044 = htobe32(0xfffffffc); *(uint32_t*)0x10000048 = htobe32(0x7f000001); *(uint32_t*)0x1000004c = htobe32(0); *(uint8_t*)0x10000050 = 1; *(uint8_t*)0x10000051 = 0x83; *(uint8_t*)0x10000052 = 0x17; *(uint8_t*)0x10000053 = 8; *(uint32_t*)0x10000054 = htobe32(0); *(uint8_t*)0x10000058 = 0xac; *(uint8_t*)0x10000059 = 0x14; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0xaa; *(uint32_t*)0x1000005c = htobe32(2); *(uint32_t*)0x10000060 = htobe32(0xe0000001); *(uint32_t*)0x10000064 = htobe32(0xe0000001); *(uint8_t*)0x10000068 = 0x89; *(uint8_t*)0x10000069 = 0x13; *(uint8_t*)0x1000006a = -1; *(uint8_t*)0x1000006b = 0xac; *(uint8_t*)0x1000006c = 0x14; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0xaa; *(uint32_t*)0x1000006f = htobe32(0xe0000002); *(uint32_t*)0x10000073 = htobe32(0xe0000001); *(uint32_t*)0x10000077 = htobe32(0xe0000001); *(uint8_t*)0x1000007b = 0x4b; *(uint8_t*)0x1000007c = 0xb; memcpy((void*)0x1000007d, "\x4f\x2b\xbb\x40\x0d\x41\xca\x92\xc7", 9); *(uint8_t*)0x10000086 = 0x94; *(uint8_t*)0x10000087 = 6; *(uint32_t*)0x10000088 = htobe32(0x1ff); *(uint8_t*)0x1000008c = 7; *(uint8_t*)0x1000008d = 0x27; *(uint8_t*)0x1000008e = 0x81; *(uint32_t*)0x1000008f = htobe32(-1); *(uint32_t*)0x10000093 = htobe32(0x7f000001); *(uint32_t*)0x10000097 = htobe32(0xe0000001); *(uint32_t*)0x1000009b = htobe32(0); *(uint8_t*)0x1000009f = 0xac; *(uint8_t*)0x100000a0 = 0x14; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0xaa; *(uint8_t*)0x100000a3 = 0xac; *(uint8_t*)0x100000a4 = 0x14; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0xbb; *(uint32_t*)0x100000a7 = htobe32(-1); *(uint32_t*)0x100000ab = htobe32(0xe0000001); *(uint32_t*)0x100000af = htobe32(0); memcpy((void*)0x100000b6, "\x5f\xea\x16\xab\x24\xfd\xf4\x39\x9d\xba\x4b\xad\xdf\x2a\x30\x45\xff\xbf\x4a\x7c\xea\xd0\x01\x98\x7b\x82\x5c\xce\x71\x89\x73\xe7\xda\x1f\x03\x08\x20\xb4\x4e\x90\x58\xc7\xd5\xe3\x87\xcc\x66\xe0\x7e\x34\xfa\x09\x42\xbf\x66\x6c\xa2\xea\xf1\x63\xcf\x19\x92\xf6\xb7\x04\x27\x91\x2f\x08\x28\x7c\x77\xb2\x70\x18\x6c\x32\x89\x6b\x16\x07\xfe\x31\x2e\x0d\x39\x21\x0e\x69\xaa\xbd\x6c\x0e\x08\x69\xb6\xe1\x50\x4d\xcf\x72\xf8\xa4\xad\x5d\xb8\xe6\xbe\xfb\xf2\x8f\xb2\xc5\x23\x32\xdd\x82\xf6\x49\x1e\xcd\x14\x66\x8d\x3e\x44\x88\x44\x65\xa9\xae\x2d\x00\xe3\x3b\x6b\x18\xfe\x5f\xb5\x86\x00\x56\x67\xc4\x0b\x9b\x86\x69\x48\xdf\x46\x9d\x4b\x4f\xca\x16\x6b\x26\xd9\x08\xe1\xed\xa7\xfc\x09\xfb\x95\x15\x80\x09\x87\xc9\x30\x7f\xb7\xf9\x1b\x74\xb4\x66\x09\x1e\x6b\xf5\x5a\x00\x9e\xa0\xe3\x76\x31\xef\xc9\x6d\x04\x78\x3d\x2e", 200); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000000e, 168); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_1); (void)res; break; case 11: memcpy((void*)0x10000180, "\xc4\xc2\xc5\xa8\x5e\x02\xc4\xe1\x7c\x29\xcd\xc4\xc1\xe0\x12\xc2\xc4\xc1\xfe\xe6\x0c\x76\xf3\x0f\x01\xa8\x00\x00\x00\x00\x0f\x3a\xcc\xbe\xf1\xff\xff\xff\xe2\xc4\xc1\xe8\x5f\x85\x35\x07\x00\x00\xc0\x91\xff\xef\xff\xff\x02\xc4\xe1\xd9\x12\x92\x0c\x00\x00\x00\xc4\xe2\x4d\x2b\xf4", 69); res = -1; errno = EFAULT; res = syz_execute_func(0x10000180); 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; } :419:17: error: use of undeclared identifier 'SYS_freebsd12_closefrom' res = syscall(SYS_freebsd12_closefrom, (intptr_t)r[5]); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor598818313 -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 (1.03s) csource_test.go:106: --- FAIL: TestGenerate/freebsd/386/0 (1.13s) csource_test.go:106: --- FAIL: TestGenerate/freebsd/386/11 (1.08s) csource_test.go:106: --- FAIL: TestGenerate/freebsd/386/13 (1.14s) csource_test.go:106: --- FAIL: TestGenerate/freebsd/386/15 (1.25s) csource_test.go:106: --- FAIL: TestGenerate/freebsd/386/10 (1.18s) csource_test.go:106: FAIL FAIL github.com/google/syzkaller/pkg/csource 11.032s ok github.com/google/syzkaller/pkg/db (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] 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 2.189s ? 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.889s ok github.com/google/syzkaller/pkg/ipc 5.590s ? 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 0.036s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig 0.113s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 4.770s ok github.com/google/syzkaller/pkg/repro 0.215s ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 52.534s 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.338s ok github.com/google/syzkaller/pkg/tool (cached) ok github.com/google/syzkaller/pkg/vcs 11.917s ok github.com/google/syzkaller/prog 13.444s 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.314s ok github.com/google/syzkaller/syz-fuzzer 0.884s ok github.com/google/syzkaller/syz-hub 0.082s ok github.com/google/syzkaller/syz-hub/state 0.204s ok github.com/google/syzkaller/syz-manager 1.497s ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-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] ok github.com/google/syzkaller/tools/syz-kconf (cached) ok github.com/google/syzkaller/tools/syz-linter 3.327s ? 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 0.104s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 0.611s ? 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 8.195s ? 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.130s ? 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.192s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL