ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 0.094s ok github.com/google/syzkaller/pkg/ast 1.869s ok github.com/google/syzkaller/pkg/bisect 84.639s ok github.com/google/syzkaller/pkg/build 2.337s ? github.com/google/syzkaller/pkg/cmdprof [no test files] ok github.com/google/syzkaller/pkg/compiler 15.369s ok github.com/google/syzkaller/pkg/config (cached) ? github.com/google/syzkaller/pkg/cover [no test files] --- FAIL: TestGenerate (9.45s) --- FAIL: TestGenerate/freebsd/386 (1.68s) csource_test.go:67: seed=1600762875644704264 --- FAIL: TestGenerate/freebsd/386/0 (1.71s) csource_test.go:123: opts: {Threaded:false Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); syscall(SYS_shmctl, 0, 0xb, 0); memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :371:10: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor499925712 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/2 (1.79s) csource_test.go:123: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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; int collide = 0; again: for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :534:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor829780098 -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/1 (1.83s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :526:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor830972911 -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.91s) csource_test.go:123: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:2 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0 + procid*1; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0 + procid*1; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0 + procid*1; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0 + procid*1; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23 + procid*4); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0 + procid*1; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20 + procid*4); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0 + procid*1; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0 + procid*1; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0 + procid*1; *(uint8_t*)0x10000031 = 0xbb; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :538:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor225737988 -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 (2.16s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:true} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; res = syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); break; case 1: *(uint8_t*)0x100000c0 = 7; res = syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; res = syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: *(uint32_t*)0x10000180 = 3; res = syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; res = syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); break; case 6: res = syscall(SYS_shmctl, 0, 0xb, 0); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); res = syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); break; case 8: *(uint32_t*)0x100008c0 = 8; res = syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; res = syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; (void)res; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); res = -1; errno = EFAULT; res = syz_execute_func(0x10000040); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; case 12: (void)res; break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :534:17: error: use of undeclared identifier 'SYS_freebsd12_shm_open' res = syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor533023891 -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 (2.52s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:setuid Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, WUNTRACED) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_setuid(void) { int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); char pwbuf[1024]; struct passwd *pw, pwres; if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw) exit(1); if (setgroups(0, NULL)) exit(1); if (setgid(pw->pw_gid)) exit(1); if (setuid(pw->pw_uid)) exit(1); loop(); exit(1); } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_setuid(); return 0; } :549:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor945434326 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/10 (2.44s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:false HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); do_sandbox_none(); return 0; } :473:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor593298493 -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 (2.34s) csource_test.go:123: 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 Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :446:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor675373162 -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 (2.70s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:true Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (sig == SIGBUS) { valid = 1; } if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) { __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 __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: NONFAILING(*(uint8_t*)0x10000000 = 0x71); NONFAILING(*(uint8_t*)0x10000001 = 0x14); NONFAILING(*(uint8_t*)0x10000002 = 1); NONFAILING(*(uint8_t*)0x10000003 = 3); NONFAILING(*(uint32_t*)0x10000004 = 0); NONFAILING(*(uint64_t*)0x10000008 = htobe64(0)); NONFAILING(*(uint64_t*)0x10000010 = htobe64(1)); NONFAILING(*(uint8_t*)0x10000018 = -1); NONFAILING(*(uint8_t*)0x10000019 = 1); NONFAILING(*(uint8_t*)0x1000001a = 0); NONFAILING(*(uint8_t*)0x1000001b = 0); NONFAILING(*(uint8_t*)0x1000001c = 0); NONFAILING(*(uint8_t*)0x1000001d = 0); NONFAILING(*(uint8_t*)0x1000001e = 0); NONFAILING(*(uint8_t*)0x1000001f = 0); NONFAILING(*(uint8_t*)0x10000020 = 0); NONFAILING(*(uint8_t*)0x10000021 = 0); NONFAILING(*(uint8_t*)0x10000022 = 0); NONFAILING(*(uint8_t*)0x10000023 = 0); NONFAILING(*(uint8_t*)0x10000024 = 0); NONFAILING(*(uint8_t*)0x10000025 = 0); NONFAILING(*(uint8_t*)0x10000026 = 0); NONFAILING(*(uint8_t*)0x10000027 = 1); NONFAILING(memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16)); NONFAILING(*(uint8_t*)0x10000038 = 0xfe); NONFAILING(*(uint8_t*)0x10000039 = 0x80); NONFAILING(*(uint8_t*)0x1000003a = 0); NONFAILING(*(uint8_t*)0x1000003b = 0); NONFAILING(*(uint8_t*)0x1000003c = 0); NONFAILING(*(uint8_t*)0x1000003d = 0); NONFAILING(*(uint8_t*)0x1000003e = 0); NONFAILING(*(uint8_t*)0x1000003f = 0); NONFAILING(*(uint8_t*)0x10000040 = 0); NONFAILING(*(uint8_t*)0x10000041 = 0); NONFAILING(*(uint8_t*)0x10000042 = 0); NONFAILING(*(uint8_t*)0x10000043 = 0); NONFAILING(*(uint8_t*)0x10000044 = 0); NONFAILING(*(uint8_t*)0x10000045 = 0); NONFAILING(*(uint8_t*)0x10000046 = 0); NONFAILING(*(uint8_t*)0x10000047 = 0xaa); NONFAILING(*(uint8_t*)0x10000048 = 0xfe); NONFAILING(*(uint8_t*)0x10000049 = 0x80); NONFAILING(*(uint8_t*)0x1000004a = 0); NONFAILING(*(uint8_t*)0x1000004b = 0); NONFAILING(*(uint8_t*)0x1000004c = 0); NONFAILING(*(uint8_t*)0x1000004d = 0); NONFAILING(*(uint8_t*)0x1000004e = 0); NONFAILING(*(uint8_t*)0x1000004f = 0); NONFAILING(*(uint8_t*)0x10000050 = 0); NONFAILING(*(uint8_t*)0x10000051 = 0); NONFAILING(*(uint8_t*)0x10000052 = 0); NONFAILING(*(uint8_t*)0x10000053 = 0); NONFAILING(*(uint8_t*)0x10000054 = 0); NONFAILING(*(uint8_t*)0x10000055 = 0); NONFAILING(*(uint8_t*)0x10000056 = 0); NONFAILING(*(uint8_t*)0x10000057 = 0xbb); NONFAILING(*(uint8_t*)0x10000058 = 0); NONFAILING(*(uint8_t*)0x10000059 = 0); NONFAILING(*(uint8_t*)0x1000005a = 0); NONFAILING(*(uint8_t*)0x1000005b = 0); NONFAILING(*(uint8_t*)0x1000005c = 0); NONFAILING(*(uint8_t*)0x1000005d = 0); NONFAILING(*(uint8_t*)0x1000005e = 0); NONFAILING(*(uint8_t*)0x1000005f = 0); NONFAILING(*(uint8_t*)0x10000060 = 0); NONFAILING(*(uint8_t*)0x10000061 = 0); NONFAILING(*(uint8_t*)0x10000062 = 0); NONFAILING(*(uint8_t*)0x10000063 = 0); NONFAILING(*(uint8_t*)0x10000064 = 0); NONFAILING(*(uint8_t*)0x10000065 = 0); NONFAILING(*(uint8_t*)0x10000066 = 0); NONFAILING(*(uint8_t*)0x10000067 = 0); NONFAILING(*(uint8_t*)0x10000068 = 0xfe); NONFAILING(*(uint8_t*)0x10000069 = 0x80); NONFAILING(*(uint8_t*)0x1000006a = 0); NONFAILING(*(uint8_t*)0x1000006b = 0); NONFAILING(*(uint8_t*)0x1000006c = 0); NONFAILING(*(uint8_t*)0x1000006d = 0); NONFAILING(*(uint8_t*)0x1000006e = 0); NONFAILING(*(uint8_t*)0x1000006f = 0); NONFAILING(*(uint8_t*)0x10000070 = 0); NONFAILING(*(uint8_t*)0x10000071 = 0); NONFAILING(*(uint8_t*)0x10000072 = 0); NONFAILING(*(uint8_t*)0x10000073 = 0); NONFAILING(*(uint8_t*)0x10000074 = 0); NONFAILING(*(uint8_t*)0x10000075 = 0); NONFAILING(*(uint8_t*)0x10000076 = 0); NONFAILING(*(uint8_t*)0x10000077 = 0xaa); NONFAILING(memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16)); NONFAILING(*(uint64_t*)0x10000088 = htobe64(0)); NONFAILING(*(uint64_t*)0x10000090 = htobe64(1)); NONFAILING(*(uint8_t*)0x10000098 = 0xfe); NONFAILING(*(uint8_t*)0x10000099 = 0x80); NONFAILING(*(uint8_t*)0x1000009a = 0); NONFAILING(*(uint8_t*)0x1000009b = 0); NONFAILING(*(uint8_t*)0x1000009c = 0); NONFAILING(*(uint8_t*)0x1000009d = 0); NONFAILING(*(uint8_t*)0x1000009e = 0); NONFAILING(*(uint8_t*)0x1000009f = 0); NONFAILING(*(uint8_t*)0x100000a0 = 0); NONFAILING(*(uint8_t*)0x100000a1 = 0); NONFAILING(*(uint8_t*)0x100000a2 = 0); NONFAILING(*(uint8_t*)0x100000a3 = 0); NONFAILING(*(uint8_t*)0x100000a4 = 0); NONFAILING(*(uint8_t*)0x100000a5 = 0); NONFAILING(*(uint8_t*)0x100000a6 = 0); NONFAILING(*(uint8_t*)0x100000a7 = 0xbb); syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: NONFAILING(*(uint8_t*)0x100000c0 = 7); syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: NONFAILING(*(uint8_t*)0x10000100 = 0x1c); NONFAILING(*(uint8_t*)0x10000101 = 0x1c); NONFAILING(*(uint16_t*)0x10000102 = htobe16(0x4e23)); NONFAILING(*(uint32_t*)0x10000104 = 0x8000); NONFAILING(*(uint8_t*)0x10000108 = 0xfe); NONFAILING(*(uint8_t*)0x10000109 = 0x80); NONFAILING(*(uint8_t*)0x1000010a = 0); NONFAILING(*(uint8_t*)0x1000010b = 0); NONFAILING(*(uint8_t*)0x1000010c = 0); NONFAILING(*(uint8_t*)0x1000010d = 0); NONFAILING(*(uint8_t*)0x1000010e = 0); NONFAILING(*(uint8_t*)0x1000010f = 0); NONFAILING(*(uint8_t*)0x10000110 = 0); NONFAILING(*(uint8_t*)0x10000111 = 0); NONFAILING(*(uint8_t*)0x10000112 = 0); NONFAILING(*(uint8_t*)0x10000113 = 0); NONFAILING(*(uint8_t*)0x10000114 = 0); NONFAILING(*(uint8_t*)0x10000115 = 0); NONFAILING(*(uint8_t*)0x10000116 = 0); NONFAILING(*(uint8_t*)0x10000117 = 0xbb); NONFAILING(*(uint32_t*)0x10000118 = 9); NONFAILING(*(uint64_t*)0x1000011c = 0); NONFAILING(*(uint64_t*)0x10000124 = 0); NONFAILING(*(uint64_t*)0x1000012c = 0); NONFAILING(*(uint64_t*)0x10000134 = 0); NONFAILING(*(uint64_t*)0x1000013c = 0); NONFAILING(*(uint64_t*)0x10000144 = 0); NONFAILING(*(uint64_t*)0x1000014c = 0); NONFAILING(*(uint64_t*)0x10000154 = 0); NONFAILING(*(uint64_t*)0x1000015c = 0); NONFAILING(*(uint64_t*)0x10000164 = 0); NONFAILING(*(uint64_t*)0x1000016c = 0); NONFAILING(*(uint64_t*)0x10000174 = 0); NONFAILING(*(uint32_t*)0x1000017c = 0); syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: NONFAILING(*(uint32_t*)0x10000180 = 3); syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: NONFAILING(*(uint32_t*)0x10000800 = 0x100001c0); NONFAILING(*(uint8_t*)0x100001c0 = 0x10); NONFAILING(*(uint8_t*)0x100001c1 = 2); NONFAILING(*(uint16_t*)0x100001c2 = htobe16(0x4e20)); NONFAILING(*(uint8_t*)0x100001c4 = 0xac); NONFAILING(*(uint8_t*)0x100001c5 = 0x14); NONFAILING(*(uint8_t*)0x100001c6 = 0); NONFAILING(*(uint8_t*)0x100001c7 = 0xbb); NONFAILING(*(uint8_t*)0x100001c8 = 0); NONFAILING(*(uint8_t*)0x100001c9 = 0); NONFAILING(*(uint8_t*)0x100001ca = 0); NONFAILING(*(uint8_t*)0x100001cb = 0); NONFAILING(*(uint8_t*)0x100001cc = 0); NONFAILING(*(uint8_t*)0x100001cd = 0); NONFAILING(*(uint8_t*)0x100001ce = 0); NONFAILING(*(uint8_t*)0x100001cf = 0); NONFAILING(*(uint32_t*)0x10000804 = 0x10); NONFAILING(*(uint32_t*)0x10000808 = 0x10000640); NONFAILING(*(uint32_t*)0x10000640 = 0x10000200); NONFAILING(*(uint32_t*)0x10000644 = 0); NONFAILING(*(uint32_t*)0x10000648 = 0x10000240); NONFAILING(memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236)); NONFAILING(*(uint32_t*)0x1000064c = 0xec); NONFAILING(*(uint32_t*)0x10000650 = 0x10000340); NONFAILING(memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171)); NONFAILING(*(uint32_t*)0x10000654 = 0xab); NONFAILING(*(uint32_t*)0x10000658 = 0x10000400); NONFAILING(*(uint32_t*)0x1000065c = 0); NONFAILING(*(uint32_t*)0x10000660 = 0x10000440); NONFAILING(memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249)); NONFAILING(*(uint32_t*)0x10000664 = 0xf9); NONFAILING(*(uint32_t*)0x10000668 = 0x10000540); NONFAILING(memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10)); NONFAILING(*(uint32_t*)0x1000066c = 0xa); NONFAILING(*(uint32_t*)0x10000670 = 0x10000580); NONFAILING(memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179)); NONFAILING(*(uint32_t*)0x10000674 = 0xb3); NONFAILING(*(uint32_t*)0x1000080c = 7); NONFAILING(*(uint32_t*)0x10000810 = 0x10000680); NONFAILING(*(uint32_t*)0x10000680 = 0xd8); NONFAILING(*(uint32_t*)0x10000684 = 0xffff); NONFAILING(*(uint32_t*)0x10000688 = 0xfffffffb); NONFAILING(memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201)); NONFAILING(*(uint32_t*)0x10000758 = 0xa4); NONFAILING(*(uint32_t*)0x1000075c = 6); NONFAILING(*(uint32_t*)0x10000760 = 8); NONFAILING(memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149)); NONFAILING(*(uint32_t*)0x10000814 = 0x17c); NONFAILING(*(uint32_t*)0x10000818 = 0); syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: NONFAILING(memcpy((void*)0x10000840, "./file0\000", 8)); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: NONFAILING(*(uint32_t*)0x100008c0 = 8); syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: NONFAILING(*(uint32_t*)0x10000940 = 0); NONFAILING(*(uint32_t*)0x10000944 = 0x10000900); NONFAILING(*(uint32_t*)0x10000980 = 8); syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: NONFAILING(memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6)); NONFAILING(*(uint8_t*)0x10000006 = 0); NONFAILING(*(uint8_t*)0x10000007 = 0); NONFAILING(*(uint8_t*)0x10000008 = 0); NONFAILING(*(uint8_t*)0x10000009 = 0); NONFAILING(*(uint8_t*)0x1000000a = 0); NONFAILING(*(uint8_t*)0x1000000b = 0); NONFAILING(*(uint16_t*)0x1000000c = htobe16(0x88a8)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12)); NONFAILING(*(uint16_t*)0x10000010 = htobe16(0x8100)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12)); NONFAILING(*(uint16_t*)0x10000014 = htobe16(0x806)); NONFAILING(*(uint16_t*)0x10000016 = htobe16(1)); NONFAILING(*(uint16_t*)0x10000018 = htobe16(0x800)); NONFAILING(*(uint8_t*)0x1000001a = 6); NONFAILING(*(uint8_t*)0x1000001b = 4); NONFAILING(*(uint16_t*)0x1000001c = htobe16(1)); NONFAILING(*(uint8_t*)0x1000001e = 0xaa); NONFAILING(*(uint8_t*)0x1000001f = 0xaa); NONFAILING(*(uint8_t*)0x10000020 = 0xaa); NONFAILING(*(uint8_t*)0x10000021 = 0xaa); NONFAILING(*(uint8_t*)0x10000022 = 0xaa); NONFAILING(*(uint8_t*)0x10000023 = 0xaa); NONFAILING(*(uint8_t*)0x10000024 = 0xac); NONFAILING(*(uint8_t*)0x10000025 = 0x14); NONFAILING(*(uint8_t*)0x10000026 = 0); NONFAILING(*(uint8_t*)0x10000027 = 0xbb); NONFAILING(*(uint8_t*)0x10000028 = 0xaa); NONFAILING(*(uint8_t*)0x10000029 = 0xaa); NONFAILING(*(uint8_t*)0x1000002a = 0xaa); NONFAILING(*(uint8_t*)0x1000002b = 0xaa); NONFAILING(*(uint8_t*)0x1000002c = 0xaa); NONFAILING(*(uint8_t*)0x1000002d = 0xaa); NONFAILING(*(uint8_t*)0x1000002e = 0xac); NONFAILING(*(uint8_t*)0x1000002f = 0x14); NONFAILING(*(uint8_t*)0x10000030 = 0); NONFAILING(*(uint8_t*)0x10000031 = 0xbb); break; case 11: NONFAILING(memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48)); NONFAILING(syz_execute_func(0x10000040)); break; case 12: break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; } :558:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor551760504 -DGOOS_freebsd=1 -DGOARCH_386=1 -DHOSTGOOS_freebsd=1 -x c - -m32 -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -static -lc++ -Wno-overflow] --- FAIL: TestGenerate/freebsd/386/7 (1.76s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/9 (2.46s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: setsockopt$inet6_IPV6_RTHDR(0xffffffffffffffff, 0x29, 0x33, &(0x7f0000000000)={0x71, 0x14, 0x1, 0x3, 0x0, [@loopback, @mcast1, @rand_addr="6a8a8a580cc4a725084c7684c07e2a14", @local={0xfe, 0x80, [], 0x0}, @remote={0xfe, 0x80, [], 0x0}, @empty, @local={0xfe, 0x80, [], 0x0}, @rand_addr="ecdd418c8078f096add3072a77955ea0", @loopback, @remote={0xfe, 0x80, [], 0x0}]}, 0xa8) setsockopt$inet6_sctp_SCTP_AUTH_CHUNK(0xffffffffffffffff, 0x84, 0x12, &(0x7f00000000c0)={0x7}, 0x1) r0 = socket$inet6_sctp(0x1c, 0x1, 0x84) setsockopt$inet6_sctp_SCTP_SET_PEER_PRIMARY_ADDR(r0, 0x84, 0x6, &(0x7f0000000100)={@in6={{0x1c, 0x1c, 0x3, 0x8000, @remote={0xfe, 0x80, [], 0x0}, 0x9}}}, 0x80) setsockopt$inet6_sctp_SCTP_DISABLE_FRAGMENTS(r0, 0x84, 0x9, &(0x7f0000000180)=0x3, 0x4) sendmsg(r0, &(0x7f0000000800)={&(0x7f00000001c0)=@in={0x10, 0x2, 0x0, @remote={0xac, 0x14, 0x0}}, 0x10, &(0x7f0000000640)=[{&(0x7f0000000200)}, {&(0x7f0000000240)="cbbf69d5ee93daca04ef5487a0b42cf08a051b4667b1af926d952a589759637e2cbabc1b5d572e77751a78e13980d9fc97ff3abb08ff17386599db9e54b5b2450d8c9d587c49d462652c5964c8d0a8b51ce449792a8a9fcd3397fdbd16b27207811e576266796d5b20d81b9b8c9ede7ec85dd361cb48d323a2cdf1ddb44dd86275a4c60b8434c50e28f46846946e403a687867d55dd688345df6d2462a74fda4719d4500f7276a51558e2aa60f61c5b0151ff4ac9b22958f8180aaca676abf2925d275b80f1165ee3af0ed9b2a46a42ad2ebf18cf89289cf5d2e8ec810c29f2f03d9ed610a5e7b0f3855515a", 0xec}, {&(0x7f0000000340)="fa26320b8f9e5da922d4313ee21e90e85dab84e195d7e15571d6d74d5edb339df643d83eb0598fff3e7f5ce92cc9bdf7fdca07ea33117f586290c2474105d909356cfc687f55d2b8fe7a9adbebbc0b730570b2353b1b3043f8f4d6f717dbee8a84a9cdb456724b355c06916e5dba857dbad01472fdf7b83f8ada93211f87516d8f7fe3352f3b7409f64dd51fcd9cfe3f98b29df463f0418caec922b609a957e5feaefea6db49406987b5d5", 0xab}, {&(0x7f0000000400)}, {&(0x7f0000000440)="bad0534abdb66ad80ab877824679627d7e71d6f8cf7cb896cce68fe24d81136b8ad614d5adc5d55ea20e911934bb2eb481957bfe1c5fda8f99d687e0fc52f9ff945c764a99bd39afd8a9a413898fedb4828e3240d1b58791c1086549a2cc4897d867be8b078ef457f5db5bb6777c307d1157e6e0a2eacb5135fc78290a424dfe214d3b8363cbebdb566f60a1170f384bbc91fb41ed4ab776e4bfa1be38fba395f31382f844af53c6ee0ba6cadde57b3ebd2c2dc16620a5f163a224f70ef1da554313a2a2ea4d16394b5b190e11e77508c0eb5ad9aea64aac2004ecb878ead09a493cfe93866aec7f11c5b6584d75fad797ec58fc620779f248", 0xf9}, {&(0x7f0000000540)="be5c9cf38b4c5722241d", 0xa}, {&(0x7f0000000580)="0f3934e8ed9dacde034a7dd45c839d6f08768d34b980e49cd5d33c713dd8d96ee7811c812cffdbc85e37e01e81e9772b93ec46660d1da35848a10033e26e0384021d1b4e3d8d6278fc32d42121f197a5aaefce8887335e52c78e2a683b06dd20ebae74aa677c5eb6cc135aae9d1d75d8a0a5c22036a6564f8610f5f208d905422398a26faf6c1fea12da3416ec9b480ae5387064b73e3c24a9f2059f6859f0cb361998b2e3f6cac7ffa22056eed227f72cedc4", 0xb3}], 0x7, &(0x7f0000000680)=[{0xd8, 0xffff, 0xfffffffb, "b000ff2aace71e2d81c3fb32e98b96953587e2cc09e43f0faa1f6c590708db6f6746f29281203d97b1bb53653f686719ecb17364c17a6b89cc28742da6006ec93fbb9cf848e046c03fa3c96e597aa85f226cf4b965a86dc05000413614e75d319127fddfa24800c7d1040fb17b3425ae8eb51d1ac1c4b278bdc12721ab2fb299e29d969d4b0bcca2fe23ea409c6924d8f01a6303de364733cc47ef8a8bf9fc4f1d2d3648eb04b1d028c05ea721d2d2c3afcefbf6bdd20734cba1c11f83fbc08369b9da7d4eea28ebca"}, {0xa4, 0x6, 0x8, "f568ae017c605d74f14f9b73f1aef8c2ff516bc0cb57eac4ba27fa1bf8317fbb64fa7bce31868baaae4a45c80253e265418b42537ea87f63ef6e0dc77941da0a4277aa096b690527c71dc5e206f5d69ef10454a1d10beb0cb6107ded9a10267eed3516145019aa0003b9055672c0b78e59dfff3797b78e8e94d2976410ed36ca8ed39e245962e28d168493c50379317edb2e6e6859"}], 0x17c}, 0x1) shmctl$SHM_LOCK(0x0, 0xb) freebsd12_shm_open(&(0x7f0000000840)='./file0\x00', 0x800, 0x100) getsockopt$inet_mreq(0xffffffffffffff9c, 0x0, 0xd, &(0x7f0000000880)={@multicast1, @loopback}, &(0x7f00000008c0)=0x8) getsockopt$inet6_sctp_SCTP_GET_LOCAL_ADDRESSES(r0, 0x84, 0x8004, &(0x7f0000000940)={0x0, &(0x7f0000000900)=[@in={0x10, 0x2, 0xffffffffffffffff, @local}]}, &(0x7f0000000980)=0x8) syz_emit_ethernet(0x32, &(0x7f0000000000)={@random="4c0e286905c6", @empty, [{[{0x88a8, 0x0, 0x0, 0x2}], {0x8100, 0x3, 0x0, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @local, @remote={0xac, 0x14, 0x0}, @local, @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="36f30fa7d8c4e20d29493dff5a000f1803c4c279b64003c4c209de04123e660f3a17e30d0f381cfe0f73f513f30f1efa") syz_extract_tcp_res(&(0x7f0000000080), 0x3, 0x10000) csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static int tunfd = -1; #define MAX_TUN 4 #define TUN_IFACE "tap%d" #define TUN_DEVICE "/dev/tap%d" #define LOCAL_MAC "aa:aa:aa:aa:aa:aa" #define REMOTE_MAC "aa:aa:aa:aa:aa:bb" #define LOCAL_IPV4 "172.20.%d.170" #define REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv = vsnprintf(str, size, format, args); if (rv < 0) exit(1); if ((size_t)rv >= size) exit(1); } static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } #define COMMAND_MAX_LEN 128 #define PATH_PREFIX "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) static void execute_command(bool panic, const char* format, ...) { va_list args; va_start(args, format); char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; memcpy(command, PATH_PREFIX, PATH_PREFIX_LEN); vsnprintf_check(command + PATH_PREFIX_LEN, COMMAND_MAX_LEN, format, args); va_end(args); int rv = system(command); if (rv) { if (panic) exit(1); } } static void initialize_tun(int tun_id) { if (tun_id < 0 || tun_id >= MAX_TUN) { exit(1); } char tun_device[sizeof(TUN_DEVICE)]; snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id); char tun_iface[sizeof(TUN_IFACE)]; snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id); execute_command(0, "ifconfig %s destroy", tun_device); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); if ((tunfd < 0) && (errno == ENOENT)) { execute_command(0, "kldload -q if_tap"); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); } if (tunfd == -1) { printf("tun: can't open %s: errno=%d\n", tun_device, errno); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; char local_mac[sizeof(LOCAL_MAC)]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC); execute_command(1, "ifconfig %s ether %s", tun_iface, local_mac); char local_ipv4[sizeof(LOCAL_IPV4)]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id); execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4); char remote_mac[sizeof(REMOTE_MAC)]; char remote_ipv4[sizeof(REMOTE_IPV4)]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC); snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id); execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac); char local_ipv6[sizeof(LOCAL_IPV6)]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id); execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6); char remote_ipv6[sizeof(REMOTE_IPV6)]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id); execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac); } static long syz_emit_ethernet(volatile long a0, volatile long a1) { if (tunfd < 0) return (uintptr_t)-1; size_t length = a0; const char* data = (char*)a1; return write(tunfd, data, length); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; exit(1); } return rv; } struct tcp_resources { uint32_t seq; uint32_t ack; }; static long syz_extract_tcp_res(volatile long a0, volatile long a1, volatile long a2) { if (tunfd < 0) return (uintptr_t)-1; char data[1000]; int rv = read_tun(&data[0], sizeof(data)); if (rv == -1) return (uintptr_t)-1; size_t length = rv; if (length < sizeof(struct ether_header)) return (uintptr_t)-1; struct ether_header* ethhdr = (struct ether_header*)&data[0]; struct tcphdr* tcphdr = 0; if (ethhdr->ether_type == htons(ETHERTYPE_IP)) { if (length < sizeof(struct ether_header) + sizeof(struct ip)) return (uintptr_t)-1; struct ip* iphdr = (struct ip*)&data[sizeof(struct ether_header)]; if (iphdr->ip_p != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + iphdr->ip_hl * 4 + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + iphdr->ip_hl * 4]; } else { if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr)) return (uintptr_t)-1; struct ip6_hdr* ipv6hdr = (struct ip6_hdr*)&data[sizeof(struct ether_header)]; if (ipv6hdr->ip6_nxt != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + sizeof(struct ip6_hdr)]; } struct tcp_resources* res = (struct tcp_resources*)a0; res->seq = htonl(ntohl(tcphdr->th_seq) + (uint32_t)a1); res->ack = htonl(ntohl(tcphdr->th_ack) + (uint32_t)a2); return 0; } static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); initialize_tun(procid); loop(); return 0; } static long syz_execute_func(volatile long text) { 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 = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint8_t*)0x10000000 = 0x71; *(uint8_t*)0x10000001 = 0x14; *(uint8_t*)0x10000002 = 1; *(uint8_t*)0x10000003 = 3; *(uint32_t*)0x10000004 = 0; *(uint64_t*)0x10000008 = htobe64(0); *(uint64_t*)0x10000010 = htobe64(1); *(uint8_t*)0x10000018 = -1; *(uint8_t*)0x10000019 = 1; *(uint8_t*)0x1000001a = 0; *(uint8_t*)0x1000001b = 0; *(uint8_t*)0x1000001c = 0; *(uint8_t*)0x1000001d = 0; *(uint8_t*)0x1000001e = 0; *(uint8_t*)0x1000001f = 0; *(uint8_t*)0x10000020 = 0; *(uint8_t*)0x10000021 = 0; *(uint8_t*)0x10000022 = 0; *(uint8_t*)0x10000023 = 0; *(uint8_t*)0x10000024 = 0; *(uint8_t*)0x10000025 = 0; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 1; memcpy((void*)0x10000028, "\x6a\x8a\x8a\x58\x0c\xc4\xa7\x25\x08\x4c\x76\x84\xc0\x7e\x2a\x14", 16); *(uint8_t*)0x10000038 = 0xfe; *(uint8_t*)0x10000039 = 0x80; *(uint8_t*)0x1000003a = 0; *(uint8_t*)0x1000003b = 0; *(uint8_t*)0x1000003c = 0; *(uint8_t*)0x1000003d = 0; *(uint8_t*)0x1000003e = 0; *(uint8_t*)0x1000003f = 0; *(uint8_t*)0x10000040 = 0; *(uint8_t*)0x10000041 = 0; *(uint8_t*)0x10000042 = 0; *(uint8_t*)0x10000043 = 0; *(uint8_t*)0x10000044 = 0; *(uint8_t*)0x10000045 = 0; *(uint8_t*)0x10000046 = 0; *(uint8_t*)0x10000047 = 0xaa; *(uint8_t*)0x10000048 = 0xfe; *(uint8_t*)0x10000049 = 0x80; *(uint8_t*)0x1000004a = 0; *(uint8_t*)0x1000004b = 0; *(uint8_t*)0x1000004c = 0; *(uint8_t*)0x1000004d = 0; *(uint8_t*)0x1000004e = 0; *(uint8_t*)0x1000004f = 0; *(uint8_t*)0x10000050 = 0; *(uint8_t*)0x10000051 = 0; *(uint8_t*)0x10000052 = 0; *(uint8_t*)0x10000053 = 0; *(uint8_t*)0x10000054 = 0; *(uint8_t*)0x10000055 = 0; *(uint8_t*)0x10000056 = 0; *(uint8_t*)0x10000057 = 0xbb; *(uint8_t*)0x10000058 = 0; *(uint8_t*)0x10000059 = 0; *(uint8_t*)0x1000005a = 0; *(uint8_t*)0x1000005b = 0; *(uint8_t*)0x1000005c = 0; *(uint8_t*)0x1000005d = 0; *(uint8_t*)0x1000005e = 0; *(uint8_t*)0x1000005f = 0; *(uint8_t*)0x10000060 = 0; *(uint8_t*)0x10000061 = 0; *(uint8_t*)0x10000062 = 0; *(uint8_t*)0x10000063 = 0; *(uint8_t*)0x10000064 = 0; *(uint8_t*)0x10000065 = 0; *(uint8_t*)0x10000066 = 0; *(uint8_t*)0x10000067 = 0; *(uint8_t*)0x10000068 = 0xfe; *(uint8_t*)0x10000069 = 0x80; *(uint8_t*)0x1000006a = 0; *(uint8_t*)0x1000006b = 0; *(uint8_t*)0x1000006c = 0; *(uint8_t*)0x1000006d = 0; *(uint8_t*)0x1000006e = 0; *(uint8_t*)0x1000006f = 0; *(uint8_t*)0x10000070 = 0; *(uint8_t*)0x10000071 = 0; *(uint8_t*)0x10000072 = 0; *(uint8_t*)0x10000073 = 0; *(uint8_t*)0x10000074 = 0; *(uint8_t*)0x10000075 = 0; *(uint8_t*)0x10000076 = 0; *(uint8_t*)0x10000077 = 0xaa; memcpy((void*)0x10000078, "\xec\xdd\x41\x8c\x80\x78\xf0\x96\xad\xd3\x07\x2a\x77\x95\x5e\xa0", 16); *(uint64_t*)0x10000088 = htobe64(0); *(uint64_t*)0x10000090 = htobe64(1); *(uint8_t*)0x10000098 = 0xfe; *(uint8_t*)0x10000099 = 0x80; *(uint8_t*)0x1000009a = 0; *(uint8_t*)0x1000009b = 0; *(uint8_t*)0x1000009c = 0; *(uint8_t*)0x1000009d = 0; *(uint8_t*)0x1000009e = 0; *(uint8_t*)0x1000009f = 0; *(uint8_t*)0x100000a0 = 0; *(uint8_t*)0x100000a1 = 0; *(uint8_t*)0x100000a2 = 0; *(uint8_t*)0x100000a3 = 0; *(uint8_t*)0x100000a4 = 0; *(uint8_t*)0x100000a5 = 0; *(uint8_t*)0x100000a6 = 0; *(uint8_t*)0x100000a7 = 0xbb; syscall(SYS_setsockopt, -1, 0x29, 0x33, 0x10000000, 0xa8); break; case 1: *(uint8_t*)0x100000c0 = 7; syscall(SYS_setsockopt, -1, 0x84, 0x12, 0x100000c0, 1); break; case 2: res = syscall(SYS_socket, 0x1c, 1, 0x84); if (res != -1) r[0] = res; break; case 3: *(uint8_t*)0x10000100 = 0x1c; *(uint8_t*)0x10000101 = 0x1c; *(uint16_t*)0x10000102 = htobe16(0x4e23); *(uint32_t*)0x10000104 = 0x8000; *(uint8_t*)0x10000108 = 0xfe; *(uint8_t*)0x10000109 = 0x80; *(uint8_t*)0x1000010a = 0; *(uint8_t*)0x1000010b = 0; *(uint8_t*)0x1000010c = 0; *(uint8_t*)0x1000010d = 0; *(uint8_t*)0x1000010e = 0; *(uint8_t*)0x1000010f = 0; *(uint8_t*)0x10000110 = 0; *(uint8_t*)0x10000111 = 0; *(uint8_t*)0x10000112 = 0; *(uint8_t*)0x10000113 = 0; *(uint8_t*)0x10000114 = 0; *(uint8_t*)0x10000115 = 0; *(uint8_t*)0x10000116 = 0; *(uint8_t*)0x10000117 = 0xbb; *(uint32_t*)0x10000118 = 9; *(uint64_t*)0x1000011c = 0; *(uint64_t*)0x10000124 = 0; *(uint64_t*)0x1000012c = 0; *(uint64_t*)0x10000134 = 0; *(uint64_t*)0x1000013c = 0; *(uint64_t*)0x10000144 = 0; *(uint64_t*)0x1000014c = 0; *(uint64_t*)0x10000154 = 0; *(uint64_t*)0x1000015c = 0; *(uint64_t*)0x10000164 = 0; *(uint64_t*)0x1000016c = 0; *(uint64_t*)0x10000174 = 0; *(uint32_t*)0x1000017c = 0; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 6, 0x10000100, 0x80); break; case 4: *(uint32_t*)0x10000180 = 3; syscall(SYS_setsockopt, (intptr_t)r[0], 0x84, 9, 0x10000180, 4); break; case 5: *(uint32_t*)0x10000800 = 0x100001c0; *(uint8_t*)0x100001c0 = 0x10; *(uint8_t*)0x100001c1 = 2; *(uint16_t*)0x100001c2 = htobe16(0x4e20); *(uint8_t*)0x100001c4 = 0xac; *(uint8_t*)0x100001c5 = 0x14; *(uint8_t*)0x100001c6 = 0; *(uint8_t*)0x100001c7 = 0xbb; *(uint8_t*)0x100001c8 = 0; *(uint8_t*)0x100001c9 = 0; *(uint8_t*)0x100001ca = 0; *(uint8_t*)0x100001cb = 0; *(uint8_t*)0x100001cc = 0; *(uint8_t*)0x100001cd = 0; *(uint8_t*)0x100001ce = 0; *(uint8_t*)0x100001cf = 0; *(uint32_t*)0x10000804 = 0x10; *(uint32_t*)0x10000808 = 0x10000640; *(uint32_t*)0x10000640 = 0x10000200; *(uint32_t*)0x10000644 = 0; *(uint32_t*)0x10000648 = 0x10000240; memcpy((void*)0x10000240, "\xcb\xbf\x69\xd5\xee\x93\xda\xca\x04\xef\x54\x87\xa0\xb4\x2c\xf0\x8a\x05\x1b\x46\x67\xb1\xaf\x92\x6d\x95\x2a\x58\x97\x59\x63\x7e\x2c\xba\xbc\x1b\x5d\x57\x2e\x77\x75\x1a\x78\xe1\x39\x80\xd9\xfc\x97\xff\x3a\xbb\x08\xff\x17\x38\x65\x99\xdb\x9e\x54\xb5\xb2\x45\x0d\x8c\x9d\x58\x7c\x49\xd4\x62\x65\x2c\x59\x64\xc8\xd0\xa8\xb5\x1c\xe4\x49\x79\x2a\x8a\x9f\xcd\x33\x97\xfd\xbd\x16\xb2\x72\x07\x81\x1e\x57\x62\x66\x79\x6d\x5b\x20\xd8\x1b\x9b\x8c\x9e\xde\x7e\xc8\x5d\xd3\x61\xcb\x48\xd3\x23\xa2\xcd\xf1\xdd\xb4\x4d\xd8\x62\x75\xa4\xc6\x0b\x84\x34\xc5\x0e\x28\xf4\x68\x46\x94\x6e\x40\x3a\x68\x78\x67\xd5\x5d\xd6\x88\x34\x5d\xf6\xd2\x46\x2a\x74\xfd\xa4\x71\x9d\x45\x00\xf7\x27\x6a\x51\x55\x8e\x2a\xa6\x0f\x61\xc5\xb0\x15\x1f\xf4\xac\x9b\x22\x95\x8f\x81\x80\xaa\xca\x67\x6a\xbf\x29\x25\xd2\x75\xb8\x0f\x11\x65\xee\x3a\xf0\xed\x9b\x2a\x46\xa4\x2a\xd2\xeb\xf1\x8c\xf8\x92\x89\xcf\x5d\x2e\x8e\xc8\x10\xc2\x9f\x2f\x03\xd9\xed\x61\x0a\x5e\x7b\x0f\x38\x55\x51\x5a", 236); *(uint32_t*)0x1000064c = 0xec; *(uint32_t*)0x10000650 = 0x10000340; memcpy((void*)0x10000340, "\xfa\x26\x32\x0b\x8f\x9e\x5d\xa9\x22\xd4\x31\x3e\xe2\x1e\x90\xe8\x5d\xab\x84\xe1\x95\xd7\xe1\x55\x71\xd6\xd7\x4d\x5e\xdb\x33\x9d\xf6\x43\xd8\x3e\xb0\x59\x8f\xff\x3e\x7f\x5c\xe9\x2c\xc9\xbd\xf7\xfd\xca\x07\xea\x33\x11\x7f\x58\x62\x90\xc2\x47\x41\x05\xd9\x09\x35\x6c\xfc\x68\x7f\x55\xd2\xb8\xfe\x7a\x9a\xdb\xeb\xbc\x0b\x73\x05\x70\xb2\x35\x3b\x1b\x30\x43\xf8\xf4\xd6\xf7\x17\xdb\xee\x8a\x84\xa9\xcd\xb4\x56\x72\x4b\x35\x5c\x06\x91\x6e\x5d\xba\x85\x7d\xba\xd0\x14\x72\xfd\xf7\xb8\x3f\x8a\xda\x93\x21\x1f\x87\x51\x6d\x8f\x7f\xe3\x35\x2f\x3b\x74\x09\xf6\x4d\xd5\x1f\xcd\x9c\xfe\x3f\x98\xb2\x9d\xf4\x63\xf0\x41\x8c\xae\xc9\x22\xb6\x09\xa9\x57\xe5\xfe\xae\xfe\xa6\xdb\x49\x40\x69\x87\xb5\xd5", 171); *(uint32_t*)0x10000654 = 0xab; *(uint32_t*)0x10000658 = 0x10000400; *(uint32_t*)0x1000065c = 0; *(uint32_t*)0x10000660 = 0x10000440; memcpy((void*)0x10000440, "\xba\xd0\x53\x4a\xbd\xb6\x6a\xd8\x0a\xb8\x77\x82\x46\x79\x62\x7d\x7e\x71\xd6\xf8\xcf\x7c\xb8\x96\xcc\xe6\x8f\xe2\x4d\x81\x13\x6b\x8a\xd6\x14\xd5\xad\xc5\xd5\x5e\xa2\x0e\x91\x19\x34\xbb\x2e\xb4\x81\x95\x7b\xfe\x1c\x5f\xda\x8f\x99\xd6\x87\xe0\xfc\x52\xf9\xff\x94\x5c\x76\x4a\x99\xbd\x39\xaf\xd8\xa9\xa4\x13\x89\x8f\xed\xb4\x82\x8e\x32\x40\xd1\xb5\x87\x91\xc1\x08\x65\x49\xa2\xcc\x48\x97\xd8\x67\xbe\x8b\x07\x8e\xf4\x57\xf5\xdb\x5b\xb6\x77\x7c\x30\x7d\x11\x57\xe6\xe0\xa2\xea\xcb\x51\x35\xfc\x78\x29\x0a\x42\x4d\xfe\x21\x4d\x3b\x83\x63\xcb\xeb\xdb\x56\x6f\x60\xa1\x17\x0f\x38\x4b\xbc\x91\xfb\x41\xed\x4a\xb7\x76\xe4\xbf\xa1\xbe\x38\xfb\xa3\x95\xf3\x13\x82\xf8\x44\xaf\x53\xc6\xee\x0b\xa6\xca\xdd\xe5\x7b\x3e\xbd\x2c\x2d\xc1\x66\x20\xa5\xf1\x63\xa2\x24\xf7\x0e\xf1\xda\x55\x43\x13\xa2\xa2\xea\x4d\x16\x39\x4b\x5b\x19\x0e\x11\xe7\x75\x08\xc0\xeb\x5a\xd9\xae\xa6\x4a\xac\x20\x04\xec\xb8\x78\xea\xd0\x9a\x49\x3c\xfe\x93\x86\x6a\xec\x7f\x11\xc5\xb6\x58\x4d\x75\xfa\xd7\x97\xec\x58\xfc\x62\x07\x79\xf2\x48", 249); *(uint32_t*)0x10000664 = 0xf9; *(uint32_t*)0x10000668 = 0x10000540; memcpy((void*)0x10000540, "\xbe\x5c\x9c\xf3\x8b\x4c\x57\x22\x24\x1d", 10); *(uint32_t*)0x1000066c = 0xa; *(uint32_t*)0x10000670 = 0x10000580; memcpy((void*)0x10000580, "\x0f\x39\x34\xe8\xed\x9d\xac\xde\x03\x4a\x7d\xd4\x5c\x83\x9d\x6f\x08\x76\x8d\x34\xb9\x80\xe4\x9c\xd5\xd3\x3c\x71\x3d\xd8\xd9\x6e\xe7\x81\x1c\x81\x2c\xff\xdb\xc8\x5e\x37\xe0\x1e\x81\xe9\x77\x2b\x93\xec\x46\x66\x0d\x1d\xa3\x58\x48\xa1\x00\x33\xe2\x6e\x03\x84\x02\x1d\x1b\x4e\x3d\x8d\x62\x78\xfc\x32\xd4\x21\x21\xf1\x97\xa5\xaa\xef\xce\x88\x87\x33\x5e\x52\xc7\x8e\x2a\x68\x3b\x06\xdd\x20\xeb\xae\x74\xaa\x67\x7c\x5e\xb6\xcc\x13\x5a\xae\x9d\x1d\x75\xd8\xa0\xa5\xc2\x20\x36\xa6\x56\x4f\x86\x10\xf5\xf2\x08\xd9\x05\x42\x23\x98\xa2\x6f\xaf\x6c\x1f\xea\x12\xda\x34\x16\xec\x9b\x48\x0a\xe5\x38\x70\x64\xb7\x3e\x3c\x24\xa9\xf2\x05\x9f\x68\x59\xf0\xcb\x36\x19\x98\xb2\xe3\xf6\xca\xc7\xff\xa2\x20\x56\xee\xd2\x27\xf7\x2c\xed\xc4", 179); *(uint32_t*)0x10000674 = 0xb3; *(uint32_t*)0x1000080c = 7; *(uint32_t*)0x10000810 = 0x10000680; *(uint32_t*)0x10000680 = 0xd8; *(uint32_t*)0x10000684 = 0xffff; *(uint32_t*)0x10000688 = 0xfffffffb; memcpy((void*)0x1000068c, "\xb0\x00\xff\x2a\xac\xe7\x1e\x2d\x81\xc3\xfb\x32\xe9\x8b\x96\x95\x35\x87\xe2\xcc\x09\xe4\x3f\x0f\xaa\x1f\x6c\x59\x07\x08\xdb\x6f\x67\x46\xf2\x92\x81\x20\x3d\x97\xb1\xbb\x53\x65\x3f\x68\x67\x19\xec\xb1\x73\x64\xc1\x7a\x6b\x89\xcc\x28\x74\x2d\xa6\x00\x6e\xc9\x3f\xbb\x9c\xf8\x48\xe0\x46\xc0\x3f\xa3\xc9\x6e\x59\x7a\xa8\x5f\x22\x6c\xf4\xb9\x65\xa8\x6d\xc0\x50\x00\x41\x36\x14\xe7\x5d\x31\x91\x27\xfd\xdf\xa2\x48\x00\xc7\xd1\x04\x0f\xb1\x7b\x34\x25\xae\x8e\xb5\x1d\x1a\xc1\xc4\xb2\x78\xbd\xc1\x27\x21\xab\x2f\xb2\x99\xe2\x9d\x96\x9d\x4b\x0b\xcc\xa2\xfe\x23\xea\x40\x9c\x69\x24\xd8\xf0\x1a\x63\x03\xde\x36\x47\x33\xcc\x47\xef\x8a\x8b\xf9\xfc\x4f\x1d\x2d\x36\x48\xeb\x04\xb1\xd0\x28\xc0\x5e\xa7\x21\xd2\xd2\xc3\xaf\xce\xfb\xf6\xbd\xd2\x07\x34\xcb\xa1\xc1\x1f\x83\xfb\xc0\x83\x69\xb9\xda\x7d\x4e\xea\x28\xeb\xca", 201); *(uint32_t*)0x10000758 = 0xa4; *(uint32_t*)0x1000075c = 6; *(uint32_t*)0x10000760 = 8; memcpy((void*)0x10000764, "\xf5\x68\xae\x01\x7c\x60\x5d\x74\xf1\x4f\x9b\x73\xf1\xae\xf8\xc2\xff\x51\x6b\xc0\xcb\x57\xea\xc4\xba\x27\xfa\x1b\xf8\x31\x7f\xbb\x64\xfa\x7b\xce\x31\x86\x8b\xaa\xae\x4a\x45\xc8\x02\x53\xe2\x65\x41\x8b\x42\x53\x7e\xa8\x7f\x63\xef\x6e\x0d\xc7\x79\x41\xda\x0a\x42\x77\xaa\x09\x6b\x69\x05\x27\xc7\x1d\xc5\xe2\x06\xf5\xd6\x9e\xf1\x04\x54\xa1\xd1\x0b\xeb\x0c\xb6\x10\x7d\xed\x9a\x10\x26\x7e\xed\x35\x16\x14\x50\x19\xaa\x00\x03\xb9\x05\x56\x72\xc0\xb7\x8e\x59\xdf\xff\x37\x97\xb7\x8e\x8e\x94\xd2\x97\x64\x10\xed\x36\xca\x8e\xd3\x9e\x24\x59\x62\xe2\x8d\x16\x84\x93\xc5\x03\x79\x31\x7e\xdb\x2e\x6e\x68\x59", 149); *(uint32_t*)0x10000814 = 0x17c; *(uint32_t*)0x10000818 = 0; syscall(SYS_sendmsg, (intptr_t)r[0], 0x10000800, 1); break; case 6: syscall(SYS_shmctl, 0, 0xb, 0); break; case 7: memcpy((void*)0x10000840, "./file0\000", 8); syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); break; case 8: *(uint32_t*)0x100008c0 = 8; syscall(SYS_getsockopt, 0xffffff9c, 0, 0xd, 0x10000880, 0x100008c0); break; case 9: *(uint32_t*)0x10000940 = 0; *(uint32_t*)0x10000944 = 0x10000900; *(uint32_t*)0x10000980 = 8; syscall(SYS_getsockopt, (intptr_t)r[0], 0x84, 0x8004, 0x10000940, 0x10000980); break; case 10: memcpy((void*)0x10000000, "\x4c\x0e\x28\x69\x05\xc6", 6); *(uint8_t*)0x10000006 = 0; *(uint8_t*)0x10000007 = 0; *(uint8_t*)0x10000008 = 0; *(uint8_t*)0x10000009 = 0; *(uint8_t*)0x1000000a = 0; *(uint8_t*)0x1000000b = 0; *(uint16_t*)0x1000000c = htobe16(0x88a8); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x1000000e, 2, 4, 12); *(uint16_t*)0x10000010 = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x10000012, 3, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x10000012, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x10000012, 4, 4, 12); *(uint16_t*)0x10000014 = htobe16(0x806); *(uint16_t*)0x10000016 = htobe16(1); *(uint16_t*)0x10000018 = htobe16(0x800); *(uint8_t*)0x1000001a = 6; *(uint8_t*)0x1000001b = 4; *(uint16_t*)0x1000001c = htobe16(1); *(uint8_t*)0x1000001e = 0xaa; *(uint8_t*)0x1000001f = 0xaa; *(uint8_t*)0x10000020 = 0xaa; *(uint8_t*)0x10000021 = 0xaa; *(uint8_t*)0x10000022 = 0xaa; *(uint8_t*)0x10000023 = 0xaa; *(uint8_t*)0x10000024 = 0xac; *(uint8_t*)0x10000025 = 0x14; *(uint8_t*)0x10000026 = 0; *(uint8_t*)0x10000027 = 0xbb; *(uint8_t*)0x10000028 = 0xaa; *(uint8_t*)0x10000029 = 0xaa; *(uint8_t*)0x1000002a = 0xaa; *(uint8_t*)0x1000002b = 0xaa; *(uint8_t*)0x1000002c = 0xaa; *(uint8_t*)0x1000002d = 0xaa; *(uint8_t*)0x1000002e = 0xac; *(uint8_t*)0x1000002f = 0x14; *(uint8_t*)0x10000030 = 0; *(uint8_t*)0x10000031 = 0xbb; syz_emit_ethernet(0x32, 0x10000000); break; case 11: memcpy((void*)0x10000040, "\x36\xf3\x0f\xa7\xd8\xc4\xe2\x0d\x29\x49\x3d\xff\x5a\x00\x0f\x18\x03\xc4\xc2\x79\xb6\x40\x03\xc4\xc2\x09\xde\x04\x12\x3e\x66\x0f\x3a\x17\xe3\x0d\x0f\x38\x1c\xfe\x0f\x73\xf5\x13\xf3\x0f\x1e\xfa", 48); syz_execute_func(0x10000040); break; case 12: syz_extract_tcp_res(0x10000080, 3, 0x10000); break; } } int main(void) { syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); use_temporary_dir(); do_sandbox_none(); return 0; } :698:11: error: use of undeclared identifier 'SYS_freebsd12_shm_open' syscall(SYS_freebsd12_shm_open, 0x10000840, 0x800, 0x100); ^ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor374617975 -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.62s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/5 (1.98s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/4 (1.94s) csource_test.go:121: --- FAIL: TestGenerate/freebsd/386/12 (1.95s) csource_test.go:121: FAIL FAIL github.com/google/syzkaller/pkg/csource 20.263s 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.983s ? 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 4.064s ok github.com/google/syzkaller/pkg/ipc 8.548s ? 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 0.124s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 9.201s ok github.com/google/syzkaller/pkg/repro 2.324s ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 75.768s 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.513s ok github.com/google/syzkaller/pkg/vcs 12.917s ok github.com/google/syzkaller/prog 22.976s 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 0.330s ? 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 2.239s ok github.com/google/syzkaller/syz-fuzzer 1.021s ok github.com/google/syzkaller/syz-hub 0.093s 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] ok github.com/google/syzkaller/tools/syz-linter 2.363s ? 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 0.063s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 0.510s ? 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 11.355s ? 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