ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 0.052s ok github.com/google/syzkaller/pkg/ast 1.620s ok github.com/google/syzkaller/pkg/bisect 82.448s ok github.com/google/syzkaller/pkg/build 1.138s ? github.com/google/syzkaller/pkg/cmdprof [no test files] ok github.com/google/syzkaller/pkg/compiler 6.005s ok github.com/google/syzkaller/pkg/config (cached) ? github.com/google/syzkaller/pkg/cover [no test files] --- FAIL: TestGenerate (6.08s) --- FAIL: TestGenerate/freebsd/386 (0.58s) csource_test.go:66: seed=1597318189413018206 --- FAIL: TestGenerate/freebsd/386/0 (0.90s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((void (*)(void))(text))(); return 0; } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_one(void) { intptr_t res = 0; res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); syscall(SYS_socket, 0x1c, 1, 0x84); memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :201:10: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor294794285 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/8 (0.85s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, WUNTRACED) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_setuid(void) { int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); char pwbuf[1024]; struct passwd *pw, pwres; if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw) exit(1); if (setgroups(0, NULL)) exit(1); if (setgid(pw->pw_gid)) exit(1); if (setuid(pw->pw_uid)) exit(1); loop(); exit(1); } static long syz_execute_func(volatile long text) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_setuid(); return 0; } :374:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor795578280 -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.03s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:true} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; res = syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; res = syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; res = syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; res = syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); break; case 8: res = syscall(SYS_socket, 0x1c, 1, 0x84); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); res = syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); (void)res; break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); res = -1; errno = EFAULT; res = syz_execute_func(0x10000140); 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; } :356:17: error: use of undeclared identifier 'SYS_copy_file_range' res = syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor273980135 -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.29s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0 + procid*1; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0 + procid*1; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0 + procid*1; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22 + procid*4); *(uint16_t*)0x10000094 = htobe16(0x4e21 + procid*4); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); 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; } :363:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor249692442 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/11 (1.55s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:true Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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(...) { __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); if (_setjmp(segv_env) == 0) { __VA_ARGS__; } __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); } 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: NONFAILING(*(uint32_t*)0x10001000 = 3); syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: NONFAILING(*(uint64_t*)0x10001040 = 0); NONFAILING(*(uint64_t*)0x10001080 = 0x12e1); syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: NONFAILING(*(uint16_t*)0x100010c0 = 4); NONFAILING(*(uint16_t*)0x100010c2 = 0x1c0); NONFAILING(*(uint16_t*)0x100010c4 = 0x1010); NONFAILING(*(uint32_t*)0x100010c8 = 1); NONFAILING(*(uint32_t*)0x100010cc = 0x3ff); NONFAILING(*(uint32_t*)0x100010d0 = 0); NONFAILING(*(uint32_t*)0x100010d4 = 1); NONFAILING(*(uint32_t*)0x100010d8 = 0xfff); NONFAILING(*(uint32_t*)0x100010dc = 0); NONFAILING(*(uint32_t*)0x10001100 = 0x20); res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) NONFAILING(r[2] = *(uint32_t*)0x100010dc); break; case 6: NONFAILING(*(uint32_t*)0x10001140 = r[2]); syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: NONFAILING(*(uint16_t*)0x10001180 = 3); NONFAILING(*(uint16_t*)0x10001182 = 0x400); NONFAILING(*(uint32_t*)0x10001184 = 0x2f4b); NONFAILING(*(uint32_t*)0x10001188 = 3); NONFAILING(*(uint32_t*)0x1000118c = 0); syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: NONFAILING(memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32)); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: NONFAILING(*(uint8_t*)0x10000000 = -1); NONFAILING(*(uint8_t*)0x10000001 = -1); NONFAILING(*(uint8_t*)0x10000002 = -1); NONFAILING(*(uint8_t*)0x10000003 = -1); NONFAILING(*(uint8_t*)0x10000004 = -1); NONFAILING(*(uint8_t*)0x10000005 = -1); NONFAILING(memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6)); NONFAILING(*(uint16_t*)0x1000000c = htobe16(0x800)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6)); NONFAILING(*(uint16_t*)0x10000010 = htobe16(0x12b)); NONFAILING(*(uint16_t*)0x10000012 = htobe16(0x65)); NONFAILING(*(uint16_t*)0x10000014 = htobe16(0xd096)); NONFAILING(*(uint8_t*)0x10000016 = 0x3f); NONFAILING(*(uint8_t*)0x10000017 = 0x87); NONFAILING(*(uint16_t*)0x10000018 = htobe16(0)); NONFAILING(*(uint32_t*)0x1000001a = htobe32(0xe0000002)); NONFAILING(*(uint32_t*)0x1000001e = htobe32(-1)); NONFAILING(*(uint8_t*)0x10000022 = 0x83); NONFAILING(*(uint8_t*)0x10000023 = 0x17); NONFAILING(*(uint8_t*)0x10000024 = 0x3f); NONFAILING(*(uint32_t*)0x10000025 = htobe32(0xe0000001)); NONFAILING(*(uint8_t*)0x10000029 = 0xac); NONFAILING(*(uint8_t*)0x1000002a = 0x14); NONFAILING(*(uint8_t*)0x1000002b = 0); NONFAILING(*(uint8_t*)0x1000002c = 0xaa); NONFAILING(*(uint32_t*)0x1000002d = htobe32(-1)); NONFAILING(*(uint32_t*)0x10000031 = htobe32(0)); NONFAILING(*(uint32_t*)0x10000035 = htobe32(0xe0000001)); NONFAILING(*(uint8_t*)0x10000039 = 0x44); NONFAILING(*(uint8_t*)0x1000003a = 0x1c); NONFAILING(*(uint8_t*)0x1000003b = 0); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4)); NONFAILING(*(uint32_t*)0x1000003d = htobe32(0)); NONFAILING(*(uint32_t*)0x10000041 = htobe32(0xf731)); NONFAILING(*(uint32_t*)0x10000045 = htobe32(0)); NONFAILING(*(uint32_t*)0x10000049 = htobe32(0)); NONFAILING(*(uint32_t*)0x1000004d = htobe32(0x7f000001)); NONFAILING(*(uint32_t*)0x10000051 = htobe32(7)); NONFAILING(*(uint8_t*)0x10000055 = 0); NONFAILING(*(uint8_t*)0x10000056 = 7); NONFAILING(*(uint8_t*)0x10000057 = 0x17); NONFAILING(*(uint8_t*)0x10000058 = 0x20); NONFAILING(*(uint32_t*)0x10000059 = htobe32(-1)); NONFAILING(*(uint32_t*)0x1000005d = htobe32(0x7f000001)); NONFAILING(*(uint32_t*)0x10000061 = htobe32(0xe0000002)); NONFAILING(*(uint32_t*)0x10000065 = htobe32(0xffff)); NONFAILING(*(uint8_t*)0x10000069 = 0xac); NONFAILING(*(uint8_t*)0x1000006a = 0x14); NONFAILING(*(uint8_t*)0x1000006b = 0); NONFAILING(*(uint8_t*)0x1000006c = 0xbb); NONFAILING(*(uint8_t*)0x1000006d = 0x89); NONFAILING(*(uint8_t*)0x1000006e = 0x23); NONFAILING(*(uint8_t*)0x1000006f = 5); NONFAILING(*(uint32_t*)0x10000070 = htobe32(0xe0000001)); NONFAILING(*(uint8_t*)0x10000074 = 0xac); NONFAILING(*(uint8_t*)0x10000075 = 0x14); NONFAILING(*(uint8_t*)0x10000076 = 0); NONFAILING(*(uint8_t*)0x10000077 = 0xaa); NONFAILING(*(uint32_t*)0x10000078 = htobe32(0)); NONFAILING(*(uint32_t*)0x1000007c = htobe32(0xe0000002)); NONFAILING(*(uint32_t*)0x10000080 = htobe32(0)); NONFAILING(*(uint32_t*)0x10000084 = htobe32(0xe0000001)); NONFAILING(*(uint32_t*)0x10000088 = htobe32(0xe0000001)); NONFAILING(*(uint32_t*)0x1000008c = htobe32(0x7f000001)); NONFAILING(*(uint16_t*)0x10000092 = htobe16(0x4e22)); NONFAILING(*(uint16_t*)0x10000094 = htobe16(0x4e21)); NONFAILING(*(uint16_t*)0x10000096 = htobe16(8)); NONFAILING(*(uint16_t*)0x10000098 = htobe16(0)); NONFAILING(memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159)); struct csum_inet csum_1; csum_inet_init(&csum_1); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4)); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4)); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8)); NONFAILING(*(uint16_t*)0x10000098 = csum_inet_digest(&csum_1)); struct csum_inet csum_2; csum_inet_init(&csum_2); NONFAILING(csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132)); NONFAILING(*(uint16_t*)0x10000018 = csum_inet_digest(&csum_2)); break; case 11: NONFAILING(memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53)); NONFAILING(syz_execute_func(0x10000140)); 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; } :383:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor844192177 -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.60s) csource_test.go:122: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:4 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0 + procid*1; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0 + procid*1; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0 + procid*1; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22 + procid*4); *(uint16_t*)0x10000094 = htobe16(0x4e21 + procid*4); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :353:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor840673006 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/3 (1.40s) csource_test.go:122: opts: {Threaded:true Collide:false Repeat:false 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void loop(void) { int i, call, thread; for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :276:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor676560732 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/5 (1.54s) csource_test.go:122: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:1 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :351:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor548249967 -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.71s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :351:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor429343093 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/12 (2.05s) csource_test.go:122: 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 UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: r0 = fcntl$dupfd(0xffffffffffffffff, 0x0, 0xffffffffffffffff) recvfrom$unix(r0, &(0x7f0000000000)=""/4096, 0x1000, 0x0, 0x0, 0x0) r1 = socket$inet_sctp(0x2, 0x5, 0x84) setsockopt$inet_sctp_SCTP_EXPLICIT_EOR(r1, 0x84, 0x1b, &(0x7f0000001000)=0x3, 0x4) copy_file_range(r0, &(0x7f0000001040), r1, &(0x7f0000001080)=0x12e1, 0x78, 0x0) getsockopt$inet_sctp_SCTP_DEFAULT_SEND_PARAM(0xffffffffffffffff, 0x84, 0xb, &(0x7f00000010c0)={0x4, 0x1c0, 0x1010, 0x1, 0x3ff, 0x0, 0x1, 0xfff, 0x0}, &(0x7f0000001100)=0x20) setsockopt$inet_sctp_SCTP_RESET_ASSOC(0xffffffffffffff9c, 0x84, 0x902, &(0x7f0000001140)=r2, 0x4) setsockopt$inet_sctp_SCTP_DEFAULT_SNDINFO(r0, 0x84, 0x21, &(0x7f0000001180)={0x3, 0x400, 0x2f4b, 0x3}, 0x10) socket$inet6_sctp(0x1c, 0x1, 0x84) ioctl$DIOCADDRULE(r0, 0xcbe04404, &(0x7f00000011c0)="e2de2116bbea464471598da2d996cce61dba592dde19cf9831bf89d53a409ec4") syz_emit_ethernet(0x139, &(0x7f0000000000)={@broadcast, @random="fd3c84dc3205", [], {@ipv4={0x800, {{0x21, 0x4, 0x2, 0x3, 0x12b, 0x65, 0xd096, 0x3f, 0x87, 0x0, @multicast2, @broadcast, {[@lsrr={0x83, 0x17, 0x3f, [@multicast1, @local={0xac, 0x14, 0x0}, @broadcast, @empty, @multicast1]}, @timestamp={0x44, 0x1c, 0x0, 0x3, 0x2, [{[@empty], 0xf731}, {[@empty]}, {[@loopback], 0x7}]}, @end, @rr={0x7, 0x17, 0x20, [@broadcast, @loopback, @multicast2, @rand_addr=0xffff, @remote={0xac, 0x14, 0x0}]}, @ssrr={0x89, 0x23, 0x5, [@multicast1, @local={0xac, 0x14, 0x0}, @empty, @multicast2, @empty, @multicast1, @multicast1, @loopback]}]}}, @udp={{0x2, 0x1, 0x8}, {"27ca5834d925e88297b8d7c010b6172623c32b33f5f4e5c1483a506d57d00e93a2b3e4fb25013be61834bd73473dd58fbd214d31821a9b759b481621e716d8b00bb65feb85baf246b63e328d03026ce4a5dfacde48405cecc5737f4b5541d1e0abc54e0491d9bc44759abdd61c0646b3f77772d2ba8f0cd88bc59be6e775d548af669d81bb0888651bcb049859b91e707f52664eaa5a107d59f98b64f8c9c5"}}}}}}) syz_execute_func(&(0x7f0000000140)="8fc878c259ec057f44c4c34569a00f000000fac4e20502d865f30f1ed6c4c2b5b99d06000000f0015e46660f2a62ff2e0f310f0de1") syz_extract_tcp_res(&(0x7f0000000180), 0x3, 0x1) csource_test.go:123: 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; dp = opendir(dir); if (dp == NULL) exit(1); 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; for (i = 0; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static void sandbox_common() { 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) { volatile long p[8] = {0}; (void)p; ((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; for (iter = 0;; 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: res = syscall(SYS_fcntl, -1, 0, -1); if (res != -1) r[0] = res; break; case 1: syscall(SYS_recvfrom, (intptr_t)r[0], 0x10000000, 0x1000, 0, 0, 0); break; case 2: res = syscall(SYS_socket, 2, 5, 0x84); if (res != -1) r[1] = res; break; case 3: *(uint32_t*)0x10001000 = 3; syscall(SYS_setsockopt, (intptr_t)r[1], 0x84, 0x1b, 0x10001000, 4); break; case 4: *(uint64_t*)0x10001040 = 0; *(uint64_t*)0x10001080 = 0x12e1; syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); break; case 5: *(uint16_t*)0x100010c0 = 4; *(uint16_t*)0x100010c2 = 0x1c0; *(uint16_t*)0x100010c4 = 0x1010; *(uint32_t*)0x100010c8 = 1; *(uint32_t*)0x100010cc = 0x3ff; *(uint32_t*)0x100010d0 = 0; *(uint32_t*)0x100010d4 = 1; *(uint32_t*)0x100010d8 = 0xfff; *(uint32_t*)0x100010dc = 0; *(uint32_t*)0x10001100 = 0x20; res = syscall(SYS_getsockopt, -1, 0x84, 0xb, 0x100010c0, 0x10001100); if (res != -1) r[2] = *(uint32_t*)0x100010dc; break; case 6: *(uint32_t*)0x10001140 = r[2]; syscall(SYS_setsockopt, 0xffffff9c, 0x84, 0x902, 0x10001140, 4); break; case 7: *(uint16_t*)0x10001180 = 3; *(uint16_t*)0x10001182 = 0x400; *(uint32_t*)0x10001184 = 0x2f4b; *(uint32_t*)0x10001188 = 3; *(uint32_t*)0x1000118c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 0x21, 0x10001180, 0x10); break; case 8: syscall(SYS_socket, 0x1c, 1, 0x84); break; case 9: memcpy((void*)0x100011c0, "\xe2\xde\x21\x16\xbb\xea\x46\x44\x71\x59\x8d\xa2\xd9\x96\xcc\xe6\x1d\xba\x59\x2d\xde\x19\xcf\x98\x31\xbf\x89\xd5\x3a\x40\x9e\xc4", 32); syscall(SYS_ioctl, (intptr_t)r[0], 0xcbe04404, 0x100011c0); break; case 10: *(uint8_t*)0x10000000 = -1; *(uint8_t*)0x10000001 = -1; *(uint8_t*)0x10000002 = -1; *(uint8_t*)0x10000003 = -1; *(uint8_t*)0x10000004 = -1; *(uint8_t*)0x10000005 = -1; memcpy((void*)0x10000006, "\xfd\x3c\x84\xdc\x32\x05", 6); *(uint16_t*)0x1000000c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 0x21, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 2, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x1000000f, 3, 2, 6); *(uint16_t*)0x10000010 = htobe16(0x12b); *(uint16_t*)0x10000012 = htobe16(0x65); *(uint16_t*)0x10000014 = htobe16(0xd096); *(uint8_t*)0x10000016 = 0x3f; *(uint8_t*)0x10000017 = 0x87; *(uint16_t*)0x10000018 = htobe16(0); *(uint32_t*)0x1000001a = htobe32(0xe0000002); *(uint32_t*)0x1000001e = htobe32(-1); *(uint8_t*)0x10000022 = 0x83; *(uint8_t*)0x10000023 = 0x17; *(uint8_t*)0x10000024 = 0x3f; *(uint32_t*)0x10000025 = htobe32(0xe0000001); *(uint8_t*)0x10000029 = 0xac; *(uint8_t*)0x1000002a = 0x14; *(uint8_t*)0x1000002b = 0; *(uint8_t*)0x1000002c = 0xaa; *(uint32_t*)0x1000002d = htobe32(-1); *(uint32_t*)0x10000031 = htobe32(0); *(uint32_t*)0x10000035 = htobe32(0xe0000001); *(uint8_t*)0x10000039 = 0x44; *(uint8_t*)0x1000003a = 0x1c; *(uint8_t*)0x1000003b = 0; STORE_BY_BITMASK(uint8_t, , 0x1000003c, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x1000003c, 2, 4, 4); *(uint32_t*)0x1000003d = htobe32(0); *(uint32_t*)0x10000041 = htobe32(0xf731); *(uint32_t*)0x10000045 = htobe32(0); *(uint32_t*)0x10000049 = htobe32(0); *(uint32_t*)0x1000004d = htobe32(0x7f000001); *(uint32_t*)0x10000051 = htobe32(7); *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 7; *(uint8_t*)0x10000057 = 0x17; *(uint8_t*)0x10000058 = 0x20; *(uint32_t*)0x10000059 = htobe32(-1); *(uint32_t*)0x1000005d = htobe32(0x7f000001); *(uint32_t*)0x10000061 = htobe32(0xe0000002); *(uint32_t*)0x10000065 = htobe32(0xffff); *(uint8_t*)0x10000069 = 0xac; *(uint8_t*)0x1000006a = 0x14; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0xbb; *(uint8_t*)0x1000006d = 0x89; *(uint8_t*)0x1000006e = 0x23; *(uint8_t*)0x1000006f = 5; *(uint32_t*)0x10000070 = htobe32(0xe0000001); *(uint8_t*)0x10000074 = 0xac; *(uint8_t*)0x10000075 = 0x14; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; *(uint32_t*)0x10000078 = htobe32(0); *(uint32_t*)0x1000007c = htobe32(0xe0000002); *(uint32_t*)0x10000080 = htobe32(0); *(uint32_t*)0x10000084 = htobe32(0xe0000001); *(uint32_t*)0x10000088 = htobe32(0xe0000001); *(uint32_t*)0x1000008c = htobe32(0x7f000001); *(uint16_t*)0x10000092 = htobe16(0x4e22); *(uint16_t*)0x10000094 = htobe16(0x4e21); *(uint16_t*)0x10000096 = htobe16(8); *(uint16_t*)0x10000098 = htobe16(0); memcpy((void*)0x1000009a, "\x27\xca\x58\x34\xd9\x25\xe8\x82\x97\xb8\xd7\xc0\x10\xb6\x17\x26\x23\xc3\x2b\x33\xf5\xf4\xe5\xc1\x48\x3a\x50\x6d\x57\xd0\x0e\x93\xa2\xb3\xe4\xfb\x25\x01\x3b\xe6\x18\x34\xbd\x73\x47\x3d\xd5\x8f\xbd\x21\x4d\x31\x82\x1a\x9b\x75\x9b\x48\x16\x21\xe7\x16\xd8\xb0\x0b\xb6\x5f\xeb\x85\xba\xf2\x46\xb6\x3e\x32\x8d\x03\x02\x6c\xe4\xa5\xdf\xac\xde\x48\x40\x5c\xec\xc5\x73\x7f\x4b\x55\x41\xd1\xe0\xab\xc5\x4e\x04\x91\xd9\xbc\x44\x75\x9a\xbd\xd6\x1c\x06\x46\xb3\xf7\x77\x72\xd2\xba\x8f\x0c\xd8\x8b\xc5\x9b\xe6\xe7\x75\xd5\x48\xaf\x66\x9d\x81\xbb\x08\x88\x65\x1b\xcb\x04\x98\x59\xb9\x1e\x70\x7f\x52\x66\x4e\xaa\x5a\x10\x7d\x59\xf9\x8b\x64\xf8\xc9\xc5", 159); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x1000001a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x1000001e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x10000092, 8); *(uint16_t*)0x10000098 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x1000000e, 132); *(uint16_t*)0x10000018 = csum_inet_digest(&csum_2); break; case 11: memcpy((void*)0x10000140, "\x8f\xc8\x78\xc2\x59\xec\x05\x7f\x44\xc4\xc3\x45\x69\xa0\x0f\x00\x00\x00\xfa\xc4\xe2\x05\x02\xd8\x65\xf3\x0f\x1e\xd6\xc4\xc2\xb5\xb9\x9d\x06\x00\x00\x00\xf0\x01\x5e\x46\x66\x0f\x2a\x62\xff\x2e\x0f\x31\x0f\x0d\xe1", 53); syz_execute_func(0x10000140); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :353:11: error: use of undeclared identifier 'SYS_copy_file_range' syscall(SYS_copy_file_range, (intptr_t)r[0], 0x10001040, (intptr_t)r[1], 0x10001080, 0x78ull, 0); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor790924043 -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.91s) csource_test.go:120: --- FAIL: TestGenerate/freebsd/386/10 (2.26s) csource_test.go:120: --- FAIL: TestGenerate/freebsd/386/2 (2.04s) csource_test.go:120: --- FAIL: TestGenerate/freebsd/386/7 (2.26s) csource_test.go:120: --- FAIL: TestGenerate/freebsd/386/1 (1.61s) csource_test.go:120: FAIL FAIL github.com/google/syzkaller/pkg/csource 14.104s ok github.com/google/syzkaller/pkg/db (cached) ok github.com/google/syzkaller/pkg/email (cached) ? github.com/google/syzkaller/pkg/gce [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ok github.com/google/syzkaller/pkg/host 1.197s ? github.com/google/syzkaller/pkg/html [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ? github.com/google/syzkaller/pkg/ifuzz/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/generated [no test files] ok github.com/google/syzkaller/pkg/instance 1.981s ok github.com/google/syzkaller/pkg/ipc 5.652s ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] 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 39.573s 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.195s ok github.com/google/syzkaller/pkg/vcs 6.963s 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) ? github.com/google/syzkaller/syz-manager [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-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-imagegen [no test files] ok github.com/google/syzkaller/tools/syz-linter 2.859s ? github.com/google/syzkaller/tools/syz-make [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] FAIL