ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 1.147s ok github.com/google/syzkaller/pkg/ast 2.146s ok github.com/google/syzkaller/pkg/bisect 41.937s ok github.com/google/syzkaller/pkg/build 0.128s ? github.com/google/syzkaller/pkg/cmdprof [no test files] ok github.com/google/syzkaller/pkg/compiler 9.967s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/cover (cached) ? github.com/google/syzkaller/pkg/cover/backend [no test files] --- FAIL: TestGenerate (5.07s) --- FAIL: TestGenerate/freebsd/386 (1.54s) csource_test.go:67: seed=1607969302641960161 --- FAIL: TestGenerate/freebsd/386/8 (1.46s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:setuid Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_setuid(); return 0; } :332:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor893180966 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/11 (0.97s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:true Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (sig == SIGBUS) { valid = 1; } if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) ({ int ok = 1; __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); if (_setjmp(segv_env) == 0) { __VA_ARGS__; } else ok = 0; __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); ok; }) static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: NONFAILING(*(uint32_t*)0x100000c0 = 0x95); syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: NONFAILING(*(uint64_t*)0x10000100 = 5); NONFAILING(*(uint64_t*)0x10000140 = 0x80000000); syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: NONFAILING(memcpy((void*)0x100001c0, "&&:\000", 4)); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) NONFAILING(r[0] = *(uint32_t*)0x10000180); break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: NONFAILING(*(uint32_t*)0x10000580 = 0x10000240); NONFAILING(memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119)); NONFAILING(*(uint32_t*)0x10000584 = 0x77); NONFAILING(*(uint32_t*)0x10000588 = 0x100002c0); NONFAILING(memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231)); NONFAILING(*(uint32_t*)0x1000058c = 0xe7); NONFAILING(*(uint32_t*)0x10000590 = 0x100003c0); NONFAILING(memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144)); NONFAILING(*(uint32_t*)0x10000594 = 0x90); NONFAILING(*(uint32_t*)0x10000598 = 0x10000480); NONFAILING(memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253)); NONFAILING(*(uint32_t*)0x1000059c = 0xfd); syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: NONFAILING(*(uint32_t*)0x100005c0 = 0xfff); syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: NONFAILING(*(uint32_t*)0x10000600 = htobe32(0)); NONFAILING(*(uint32_t*)0x10000604 = htobe32(0)); NONFAILING(*(uint32_t*)0x10000608 = htobe32(0)); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: NONFAILING(*(uint8_t*)0x10000000 = 0xaa); NONFAILING(*(uint8_t*)0x10000001 = 0xaa); NONFAILING(*(uint8_t*)0x10000002 = 0xaa); NONFAILING(*(uint8_t*)0x10000003 = 0xaa); NONFAILING(*(uint8_t*)0x10000004 = 0xaa); NONFAILING(*(uint8_t*)0x10000005 = 0xbb); NONFAILING(memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6)); NONFAILING(*(uint16_t*)0x1000000c = htobe16(0x806)); NONFAILING(*(uint16_t*)0x1000000e = htobe16(1)); NONFAILING(*(uint16_t*)0x10000010 = htobe16(0x800)); NONFAILING(*(uint8_t*)0x10000012 = 6); NONFAILING(*(uint8_t*)0x10000013 = 4); NONFAILING(*(uint16_t*)0x10000014 = htobe16(4)); NONFAILING(*(uint8_t*)0x10000016 = 0xaa); NONFAILING(*(uint8_t*)0x10000017 = 0xaa); NONFAILING(*(uint8_t*)0x10000018 = 0xaa); NONFAILING(*(uint8_t*)0x10000019 = 0xaa); NONFAILING(*(uint8_t*)0x1000001a = 0xaa); NONFAILING(*(uint8_t*)0x1000001b = 0xaa); NONFAILING(*(uint32_t*)0x1000001c = htobe32(0x7f000001)); NONFAILING(*(uint8_t*)0x10000020 = -1); NONFAILING(*(uint8_t*)0x10000021 = -1); NONFAILING(*(uint8_t*)0x10000022 = -1); NONFAILING(*(uint8_t*)0x10000023 = -1); NONFAILING(*(uint8_t*)0x10000024 = -1); NONFAILING(*(uint8_t*)0x10000025 = -1); NONFAILING(*(uint8_t*)0x10000026 = 0xac); NONFAILING(*(uint8_t*)0x10000027 = 0x14); NONFAILING(*(uint8_t*)0x10000028 = 0); NONFAILING(*(uint8_t*)0x10000029 = 0xaa); break; case 11: NONFAILING(memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44)); NONFAILING(syz_execute_func(0x10000040)); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; } :341:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor841349923 -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.15s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int tunfd = -1; #define MAX_TUN 4 #define TUN_IFACE "tap%d" #define TUN_DEVICE "/dev/tap%d" #define LOCAL_MAC "aa:aa:aa:aa:aa:aa" #define REMOTE_MAC "aa:aa:aa:aa:aa:bb" #define LOCAL_IPV4 "172.20.%d.170" #define REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv = vsnprintf(str, size, format, args); if (rv < 0) exit(1); if ((size_t)rv >= size) exit(1); } static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } #define COMMAND_MAX_LEN 128 #define PATH_PREFIX "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) static void execute_command(bool panic, const char* format, ...) { va_list args; va_start(args, format); char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; memcpy(command, PATH_PREFIX, PATH_PREFIX_LEN); vsnprintf_check(command + PATH_PREFIX_LEN, COMMAND_MAX_LEN, format, args); va_end(args); int rv = system(command); if (rv) { if (panic) exit(1); } } static void initialize_tun(int tun_id) { if (tun_id < 0 || tun_id >= MAX_TUN) { exit(1); } char tun_device[sizeof(TUN_DEVICE)]; snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id); char tun_iface[sizeof(TUN_IFACE)]; snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id); execute_command(0, "ifconfig %s destroy", tun_device); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); if ((tunfd < 0) && (errno == ENOENT)) { execute_command(0, "kldload -q if_tap"); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); } if (tunfd == -1) { printf("tun: can't open %s: errno=%d\n", tun_device, errno); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; char local_mac[sizeof(LOCAL_MAC)]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC); execute_command(1, "ifconfig %s ether %s", tun_iface, local_mac); char local_ipv4[sizeof(LOCAL_IPV4)]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id); execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4); char remote_mac[sizeof(REMOTE_MAC)]; char remote_ipv4[sizeof(REMOTE_IPV4)]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC); snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id); execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac); char local_ipv6[sizeof(LOCAL_IPV6)]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id); execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6); char remote_ipv6[sizeof(REMOTE_IPV6)]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id); execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac); } static long syz_emit_ethernet(volatile long a0, volatile long a1) { if (tunfd < 0) return (uintptr_t)-1; size_t length = a0; const char* data = (char*)a1; return write(tunfd, data, length); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; exit(1); } return rv; } struct tcp_resources { uint32_t seq; uint32_t ack; }; static long syz_extract_tcp_res(volatile long a0, volatile long a1, volatile long a2) { if (tunfd < 0) return (uintptr_t)-1; char data[1000]; int rv = read_tun(&data[0], sizeof(data)); if (rv == -1) return (uintptr_t)-1; size_t length = rv; if (length < sizeof(struct ether_header)) return (uintptr_t)-1; struct ether_header* ethhdr = (struct ether_header*)&data[0]; struct tcphdr* tcphdr = 0; if (ethhdr->ether_type == htons(ETHERTYPE_IP)) { if (length < sizeof(struct ether_header) + sizeof(struct ip)) return (uintptr_t)-1; struct ip* iphdr = (struct ip*)&data[sizeof(struct ether_header)]; if (iphdr->ip_p != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + iphdr->ip_hl * 4 + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + iphdr->ip_hl * 4]; } else { if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr)) return (uintptr_t)-1; struct ip6_hdr* ipv6hdr = (struct ip6_hdr*)&data[sizeof(struct ether_header)]; if (ipv6hdr->ip6_nxt != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + sizeof(struct ip6_hdr)]; } struct tcp_resources* res = (struct tcp_resources*)a0; res->seq = htonl(ntohl(tcphdr->th_seq) + (uint32_t)a1); res->ack = htonl(ntohl(tcphdr->th_ack) + (uint32_t)a2); return 0; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); initialize_tun(procid); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; syz_emit_ethernet(0x2a, 0x10000000); break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: syz_extract_tcp_res(0x10000080, 3, 0xd6); break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :481:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor491489101 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/13 (1.59s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:true} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; res = syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; res = syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: res = syscall(SYS_msgget, 0x798e7455, 0x83); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); break; case 3: res = syscall(SYS_fchmod, 0xffffff9c, 1); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: res = syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; res = syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; res = syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); res = syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: res = syscall(SYS_dup, 0xffffff9c); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; (void)res; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); res = -1; errno = EFAULT; res = syz_execute_func(0x10000040); 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; } :311:17: error: use of undeclared identifier 'SYS_copy_file_range' res = syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor129138760 -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 (1.67s) csource_test.go:123: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:2 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; int collide = 0; again: for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455 + procid*4, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0 + procid*1; *(uint8_t*)0x10000029 = 0xaa; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :321:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor185163015 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/4 (1.40s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:10 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :309:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor305950929 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/10 (1.51s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:false HandleSegv:false Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); do_sandbox_none(); return 0; } :256:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor121776636 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/0 (2.05s) csource_test.go:123: opts: {Threaded:false Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_one(void) { intptr_t res = 0; *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); syscall(SYS_msgget, 0x798e7455, 0x83); syscall(SYS_fchmod, 0xffffff9c, 1); memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); syscall(SYS_dup, 0xffffff9c); *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :168:10: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor167819450 -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.67s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } 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) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :311:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor121908011 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/7 (1.52s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox: Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$inet_buf(0xffffffffffffff9c, 0x0, 0x1, &(0x7f0000000000)=""/149, &(0x7f00000000c0)=0x95) copy_file_range(0xffffffffffffffff, &(0x7f0000000100)=0x5, 0xffffffffffffffff, &(0x7f0000000140)=0x80000000, 0x7, 0x0) msgget(0x2, 0x83) fchmod(0xffffffffffffff9c, 0x1) ksem_open(&(0x7f0000000180)=0x0, &(0x7f00000001c0)='&&:\x00', 0xa00, 0x10, 0x0) ksem_getvalue(r0, &(0x7f0000000200)) writev(0xffffffffffffff9c, &(0x7f0000000580)=[{&(0x7f0000000240)="e366e7a6d6dedca5a8cae649dd12a03535b5de7899710fd7197c5ce9633acff03ed0747859c861148333cea173068e2bd9d0a26664fb8ad620c67d23cfd50d851006f057681d2105b631791ee9ebca21c9985633b9be1282929d55f4381a85af163096661def036ee3a865cb337a054444b30d3ff78dd3", 0x77}, {&(0x7f00000002c0)="b0e6684d00a455587703f16fb501da09f2f1e7bb2fafc20ccbecb7d8f17b97b923def4446bb7025d36139c288b52222e5242a3d4750b74b80eb6003db86389dd57842baba75ed038d2dfcafefed2ff5d2c085052146fc2e591191411ed0784f7b9913587a7fc47d8b0954470f935ae7478eebf484dc947d6bc643ea853f25240394b5deee898971c3a654029065f8a6cb898f83408600c894119f51e86d1a14e6d15a684a85fb693d14c606e931af4f8cc1dcf91808a2c4b26d431682db65d7568794165d35ce9291bf0db3beb695a86ea7c8bef50422de0a212bc84ccefef521dbb9c6c38d8bd", 0xe7}, {&(0x7f00000003c0)="cc057facf0a5d2966274cec16735b8107718bd18fa06f5f36304b2ed2950ebc3b103d23434f6b15b848d52e876677086e5afd840f53f05587197f252fd028ddffec4eb62fb9a376d86e131778c7f2596f83e57aa7253bd2dcf3f54372ed63e3f642fd2db03c49da5cf310359420c9459e1fda2186380af4ffb351e79375a2777e07ae2aa6a1aab925bf2df3f9017cd1a", 0x90}, {&(0x7f0000000480)="0ec31a8aad3c4ef6bb1705e2d017508e06616be2299a37a84cfb953b6d65bd28ab5d928b6c54440ca17b41839a1dbd715d9b22fbc6eb5aea655d74d3e86b3a6d42397aab43c96b458c92e7ad9fccfc212e4ce30c46a37c42dbcf7a79a61854ab50d171f16c546f6633a8148778f1992975bad69bfacd3ca16e8e9cf16001dbdd98284d8f35d032650c91dcad11d9d92d404cc9a769faf22f8bbeccb74fbe3bd9f2fab2198130911262ef67bfd9a407b58f726e5eee433cb9bbea5335479d10477eff508f6f880b9148a822e64386fbac3b52d81ef1a7d58399eb3b1535cd37a9edc3b3aa05f2d0d658b1b90f86c897ff7c225672970a2ae4e0860246de", 0xfd}], 0x4) setsockopt$inet_udplite(0xffffffffffffffff, 0x88, 0x2, &(0x7f00000005c0)=0xfff, 0x4) setsockopt$inet_mreqsrc(0xffffffffffffff9c, 0x0, 0x49, &(0x7f0000000600), 0xc) dup(0xffffffffffffff9c) syz_emit_ethernet(0x2a, &(0x7f0000000000)={@remote, @random="5454b3304e92", [], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x4, @local, @loopback, @broadcast, @local={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="0f370ffae30f3800dfc4c27918ea8fc978d1a5193f7364f0832b60c4c1b961d7c4c27941161e670f98b00100") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0xd6) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x100000c0 = 0x95; syscall(SYS_getsockopt, 0xffffff9c, 0, 1, 0x10000000, 0x100000c0); break; case 1: *(uint64_t*)0x10000100 = 5; *(uint64_t*)0x10000140 = 0x80000000; syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); break; case 2: syscall(SYS_msgget, 0x798e7455, 0x83); break; case 3: syscall(SYS_fchmod, 0xffffff9c, 1); break; case 4: memcpy((void*)0x100001c0, "&&:\000", 4); res = syscall(SYS_ksem_open, 0x10000180, 0x100001c0, 0xa00, 0x10, 0); if (res != -1) r[0] = *(uint32_t*)0x10000180; break; case 5: syscall(SYS_ksem_getvalue, (intptr_t)r[0], 0x10000200); break; case 6: *(uint32_t*)0x10000580 = 0x10000240; memcpy((void*)0x10000240, "\xe3\x66\xe7\xa6\xd6\xde\xdc\xa5\xa8\xca\xe6\x49\xdd\x12\xa0\x35\x35\xb5\xde\x78\x99\x71\x0f\xd7\x19\x7c\x5c\xe9\x63\x3a\xcf\xf0\x3e\xd0\x74\x78\x59\xc8\x61\x14\x83\x33\xce\xa1\x73\x06\x8e\x2b\xd9\xd0\xa2\x66\x64\xfb\x8a\xd6\x20\xc6\x7d\x23\xcf\xd5\x0d\x85\x10\x06\xf0\x57\x68\x1d\x21\x05\xb6\x31\x79\x1e\xe9\xeb\xca\x21\xc9\x98\x56\x33\xb9\xbe\x12\x82\x92\x9d\x55\xf4\x38\x1a\x85\xaf\x16\x30\x96\x66\x1d\xef\x03\x6e\xe3\xa8\x65\xcb\x33\x7a\x05\x44\x44\xb3\x0d\x3f\xf7\x8d\xd3", 119); *(uint32_t*)0x10000584 = 0x77; *(uint32_t*)0x10000588 = 0x100002c0; memcpy((void*)0x100002c0, "\xb0\xe6\x68\x4d\x00\xa4\x55\x58\x77\x03\xf1\x6f\xb5\x01\xda\x09\xf2\xf1\xe7\xbb\x2f\xaf\xc2\x0c\xcb\xec\xb7\xd8\xf1\x7b\x97\xb9\x23\xde\xf4\x44\x6b\xb7\x02\x5d\x36\x13\x9c\x28\x8b\x52\x22\x2e\x52\x42\xa3\xd4\x75\x0b\x74\xb8\x0e\xb6\x00\x3d\xb8\x63\x89\xdd\x57\x84\x2b\xab\xa7\x5e\xd0\x38\xd2\xdf\xca\xfe\xfe\xd2\xff\x5d\x2c\x08\x50\x52\x14\x6f\xc2\xe5\x91\x19\x14\x11\xed\x07\x84\xf7\xb9\x91\x35\x87\xa7\xfc\x47\xd8\xb0\x95\x44\x70\xf9\x35\xae\x74\x78\xee\xbf\x48\x4d\xc9\x47\xd6\xbc\x64\x3e\xa8\x53\xf2\x52\x40\x39\x4b\x5d\xee\xe8\x98\x97\x1c\x3a\x65\x40\x29\x06\x5f\x8a\x6c\xb8\x98\xf8\x34\x08\x60\x0c\x89\x41\x19\xf5\x1e\x86\xd1\xa1\x4e\x6d\x15\xa6\x84\xa8\x5f\xb6\x93\xd1\x4c\x60\x6e\x93\x1a\xf4\xf8\xcc\x1d\xcf\x91\x80\x8a\x2c\x4b\x26\xd4\x31\x68\x2d\xb6\x5d\x75\x68\x79\x41\x65\xd3\x5c\xe9\x29\x1b\xf0\xdb\x3b\xeb\x69\x5a\x86\xea\x7c\x8b\xef\x50\x42\x2d\xe0\xa2\x12\xbc\x84\xcc\xef\xef\x52\x1d\xbb\x9c\x6c\x38\xd8\xbd", 231); *(uint32_t*)0x1000058c = 0xe7; *(uint32_t*)0x10000590 = 0x100003c0; memcpy((void*)0x100003c0, "\xcc\x05\x7f\xac\xf0\xa5\xd2\x96\x62\x74\xce\xc1\x67\x35\xb8\x10\x77\x18\xbd\x18\xfa\x06\xf5\xf3\x63\x04\xb2\xed\x29\x50\xeb\xc3\xb1\x03\xd2\x34\x34\xf6\xb1\x5b\x84\x8d\x52\xe8\x76\x67\x70\x86\xe5\xaf\xd8\x40\xf5\x3f\x05\x58\x71\x97\xf2\x52\xfd\x02\x8d\xdf\xfe\xc4\xeb\x62\xfb\x9a\x37\x6d\x86\xe1\x31\x77\x8c\x7f\x25\x96\xf8\x3e\x57\xaa\x72\x53\xbd\x2d\xcf\x3f\x54\x37\x2e\xd6\x3e\x3f\x64\x2f\xd2\xdb\x03\xc4\x9d\xa5\xcf\x31\x03\x59\x42\x0c\x94\x59\xe1\xfd\xa2\x18\x63\x80\xaf\x4f\xfb\x35\x1e\x79\x37\x5a\x27\x77\xe0\x7a\xe2\xaa\x6a\x1a\xab\x92\x5b\xf2\xdf\x3f\x90\x17\xcd\x1a", 144); *(uint32_t*)0x10000594 = 0x90; *(uint32_t*)0x10000598 = 0x10000480; memcpy((void*)0x10000480, "\x0e\xc3\x1a\x8a\xad\x3c\x4e\xf6\xbb\x17\x05\xe2\xd0\x17\x50\x8e\x06\x61\x6b\xe2\x29\x9a\x37\xa8\x4c\xfb\x95\x3b\x6d\x65\xbd\x28\xab\x5d\x92\x8b\x6c\x54\x44\x0c\xa1\x7b\x41\x83\x9a\x1d\xbd\x71\x5d\x9b\x22\xfb\xc6\xeb\x5a\xea\x65\x5d\x74\xd3\xe8\x6b\x3a\x6d\x42\x39\x7a\xab\x43\xc9\x6b\x45\x8c\x92\xe7\xad\x9f\xcc\xfc\x21\x2e\x4c\xe3\x0c\x46\xa3\x7c\x42\xdb\xcf\x7a\x79\xa6\x18\x54\xab\x50\xd1\x71\xf1\x6c\x54\x6f\x66\x33\xa8\x14\x87\x78\xf1\x99\x29\x75\xba\xd6\x9b\xfa\xcd\x3c\xa1\x6e\x8e\x9c\xf1\x60\x01\xdb\xdd\x98\x28\x4d\x8f\x35\xd0\x32\x65\x0c\x91\xdc\xad\x11\xd9\xd9\x2d\x40\x4c\xc9\xa7\x69\xfa\xf2\x2f\x8b\xbe\xcc\xb7\x4f\xbe\x3b\xd9\xf2\xfa\xb2\x19\x81\x30\x91\x12\x62\xef\x67\xbf\xd9\xa4\x07\xb5\x8f\x72\x6e\x5e\xee\x43\x3c\xb9\xbb\xea\x53\x35\x47\x9d\x10\x47\x7e\xff\x50\x8f\x6f\x88\x0b\x91\x48\xa8\x22\xe6\x43\x86\xfb\xac\x3b\x52\xd8\x1e\xf1\xa7\xd5\x83\x99\xeb\x3b\x15\x35\xcd\x37\xa9\xed\xc3\xb3\xaa\x05\xf2\xd0\xd6\x58\xb1\xb9\x0f\x86\xc8\x97\xff\x7c\x22\x56\x72\x97\x0a\x2a\xe4\xe0\x86\x02\x46\xde", 253); *(uint32_t*)0x1000059c = 0xfd; syscall(SYS_writev, 0xffffff9c, 0x10000580, 4); break; case 7: *(uint32_t*)0x100005c0 = 0xfff; syscall(SYS_setsockopt, -1, 0x88, 2, 0x100005c0, 4); break; case 8: *(uint32_t*)0x10000600 = htobe32(0); *(uint32_t*)0x10000604 = htobe32(0); *(uint32_t*)0x10000608 = htobe32(0); syscall(SYS_setsockopt, 0xffffff9c, 0, 0x49, 0x10000600, 0xc); break; case 9: syscall(SYS_dup, 0xffffff9c); break; case 10: *(uint8_t*)0x10000000 = 0xaa; *(uint8_t*)0x10000001 = 0xaa; *(uint8_t*)0x10000002 = 0xaa; *(uint8_t*)0x10000003 = 0xaa; *(uint8_t*)0x10000004 = 0xaa; *(uint8_t*)0x10000005 = 0xbb; memcpy((void*)0x10000006, "\x54\x54\xb3\x30\x4e\x92", 6); *(uint16_t*)0x1000000c = htobe16(0x806); *(uint16_t*)0x1000000e = htobe16(1); *(uint16_t*)0x10000010 = htobe16(0x800); *(uint8_t*)0x10000012 = 6; *(uint8_t*)0x10000013 = 4; *(uint16_t*)0x10000014 = htobe16(4); *(uint8_t*)0x10000016 = 0xaa; *(uint8_t*)0x10000017 = 0xaa; *(uint8_t*)0x10000018 = 0xaa; *(uint8_t*)0x10000019 = 0xaa; *(uint8_t*)0x1000001a = 0xaa; *(uint8_t*)0x1000001b = 0xaa; *(uint32_t*)0x1000001c = htobe32(0x7f000001); *(uint8_t*)0x10000020 = -1; *(uint8_t*)0x10000021 = -1; *(uint8_t*)0x10000022 = -1; *(uint8_t*)0x10000023 = -1; *(uint8_t*)0x10000024 = -1; *(uint8_t*)0x10000025 = -1; *(uint8_t*)0x10000026 = 0xac; *(uint8_t*)0x10000027 = 0x14; *(uint8_t*)0x10000028 = 0; *(uint8_t*)0x10000029 = 0xaa; break; case 11: memcpy((void*)0x10000040, "\x0f\x37\x0f\xfa\xe3\x0f\x38\x00\xdf\xc4\xc2\x79\x18\xea\x8f\xc9\x78\xd1\xa5\x19\x3f\x73\x64\xf0\x83\x2b\x60\xc4\xc1\xb9\x61\xd7\xc4\xc2\x79\x41\x16\x1e\x67\x0f\x98\xb0\x01\x00", 44); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); loop(); return 0; } :282:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, -1, 0x10000100, -1, 0x10000140, 7ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor590048398 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/6 (1.30s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/2 (0.96s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/5 (1.45s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/1 (1.05s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/3 (1.27s) csource_test.go:121: FAIL FAIL github.com/google/syzkaller/pkg/csource 13.013s 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 1.256s ? 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.191s ok github.com/google/syzkaller/pkg/ipc 3.946s ? 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.048s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig (cached) ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report (cached) ok github.com/google/syzkaller/pkg/repro (cached) ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 56.260s 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.247s ok github.com/google/syzkaller/pkg/vcs 9.362s ok github.com/google/syzkaller/prog (cached) ok github.com/google/syzkaller/prog/test (cached) ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ok github.com/google/syzkaller/sys/linux (cached) ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ok github.com/google/syzkaller/sys/openbsd (cached) ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ok github.com/google/syzkaller/syz-ci (cached) ok github.com/google/syzkaller/syz-fuzzer (cached) ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager 0.867s ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ? github.com/google/syzkaller/tools/syz-kconf [no test files] ok github.com/google/syzkaller/tools/syz-linter 3.015s ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/parser (cached) ok github.com/google/syzkaller/tools/syz-trace2syz/proggen (cached) ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ok github.com/google/syzkaller/vm (cached) ? 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 (cached) ? 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 (cached) ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL