ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 0.590s ok github.com/google/syzkaller/pkg/ast 4.281s ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect (cached) ok github.com/google/syzkaller/pkg/build (cached) ok github.com/google/syzkaller/pkg/compiler 15.242s ? github.com/google/syzkaller/pkg/config [no test files] ok github.com/google/syzkaller/pkg/cover (cached) ok github.com/google/syzkaller/pkg/cover/backend (cached) --- FAIL: TestGenerate (6.60s) --- FAIL: TestGenerate/openbsd/amd64 (0.10s) csource_test.go:52: seed=1633434971138750587 --- FAIL: TestGenerate/openbsd/amd64/13 (1.90s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :341:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :339:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3446640578 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/14 (2.02s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:true LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { fprintf(stderr, "### start\n"); int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); res = syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); break; case 1: res = syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; res = syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: res = syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); res = syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; res = syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[2] = res; break; case 9: res = syscall(SYS_ioctl, r[2], 0x20004269ul, 0); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); res = -1; errno = EFAULT; res = syz_execute_func(0x20000300); fprintf(stderr, "### call=10 errno=%u\n", res == -1 ? errno : 0); break; case 11: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :340:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :338:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor212991963 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/4 (1.66s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:10 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :339:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :337:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1338513808 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/0 (2.16s) csource_test.go:118: opts: {Threaded:false Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { if (setsid() == -1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; syscall(SYS_ioctl, r[2], 0x20004269ul, 0); memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); syz_open_pts(); } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :202:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :200:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4237502708 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/8 (2.13s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox: Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); loop(); return 0; } :314:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :312:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2994952818 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/9 (1.92s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:setuid Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, WUNTRACED) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_setuid(void) { int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); char pwbuf[1024]; struct passwd *pw, pwres; if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw) exit(1); if (setgroups(0, NULL)) exit(1); if (setgid(pw->pw_gid)) exit(1); if (setuid(pw->pw_uid)) exit(1); loop(); exit(1); } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_setuid(); return 0; } :362:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :360:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor251712352 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/15 (2.17s) csource_test.go:118: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:2 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; int collide = 0; again: for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :351:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :349:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3931190995 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/11 (2.01s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:false HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { 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 < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); do_sandbox_none(); return 0; } :287:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :285:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2717422553 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/6 (1.55s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:4 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :341:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :339:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2935175947 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/10 (2.11s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: ioctl$BIOCSFILDROP(0xffffffffffffffff, 0x80044279, &(0x7f0000000000)=0x7fff) (fail_nth: 1) ioctl$BIOCGDIRFILT(0xffffffffffffffff, 0x4004427c, &(0x7f0000000040)) r0 = openat$pf(0xffffffffffffff9c, &(0x7f0000000080), 0x80, 0x0) ioctl$TIOCSWINSZ(r0, 0x80087467, &(0x7f00000000c0)={0x100, 0x8, 0x6, 0x9}) ioctl$BIOCGETIF(r0, 0x4020426b, &(0x7f0000000100)={""/16, @ifru_broadaddr=@in}) r1 = socket$inet6(0x18, 0x4000, 0x0) pwrite(r1, &(0x7f0000000140)="0b6199933040520d3a2a08e1f7b4b384694f80cdb5c2eb41f1d882dabf02c62b6932b03724a6cfc9584482d8f5e18049fb7c5fc7d2c0998c5c661c0203d6fc0a9816560f54d6206871331658f579429907049ef1379ea246f6328a950815f3e2000fcd3a76c285b24a38bc3f7457489e91197ae89321e19d43977f61b441e2cbcff6744d13b7cd2053be56d94aa43c85e69d856f861523c3c5865f187830d38b327fc905898b77cf4910ea0656c5f438dff6112cb2500a1b699e64ea9f594739fdcd40e924198215cf7185b25acb212045d6597e4181cfa3823c392c02f5b3ed3414b43bb86092fb8bb29224c9fe20b350627e0f212824a399b8c74b61", 0xfd, 0x0, 0x1) ioctl$TIOCSETD(r0, 0x8004741b, &(0x7f0000000240)=0xf1ae537) r2 = dup2(r1, r1) ioctl$BIOCPROMISC(r2, 0x20004269) syz_emit_ethernet(0x2eb, &(0x7f0000000000)={@empty, @broadcast, [], {@ipv6={0x86dd, {0x0, 0x6, "fdb6cf", 0x2b5, 0x0, 0x40, @rand_addr="a7c9ebf4ac230852466ce7f4604d70a9", @loopback, {[@fragment={0x88, 0x0, 0x3f, 0x0, 0x0, 0x1, 0x65}, @fragment={0x0, 0x0, 0x6, 0x0, 0x0, 0x3, 0x65}, @dstopts={0x8, 0x4, '\x00', [@pad1, @jumbo, @pad1, @jumbo={0xc2, 0x4, 0x7fff}, @enc_lim={0x4, 0x1, 0x1}, @ra={0x5, 0x2, 0x7f}, @jumbo={0xc2, 0x4, 0xff}, @padn={0x1, 0x2, [0x0, 0x0]}]}, @dstopts={0xff, 0x2f, '\x00', [@generic={0x7f, 0xc3, "a2860e177e3951ac9a2ddbba864cdfe7809d7c7f5ec8d3d02c1596145f31b13aaf0b041b587d0dcdfe861cce1c10c31b972a5b62024f50a2febcbe28eb405e5fcb15b1c482564467009f896f2f81ca40db0132798faa82dd54bcb7167d08edc86c67c36518b6025e5183ebc8aa1cf9b434b10e01b9d338b5077f832c77467d18da55eef380eeb0a53873cac9a6e78a9f3f94841b7dc1682896132101f3f6f1b85067d6221a8b297ef8c63ef3177e3b26e2b870ffcacec952615c259ce4c20d4f71ebcd"}, @ra={0x5, 0x2, 0x3}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @padn={0x1, 0x6, [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]}, @generic={0xff, 0x45, "a8c543ddebe705cfe14775e8c7c29df2b8936b923778a0afa0d56f418c6b6836f8d569f9d4b9323b01af68577636d29acaea5db4b890483631f296ab36a7f0b4c1d0d00e4e"}, @generic={0x20, 0x54, "49a0b18629aa76bad39945ce37aa362127de1d046de676b7ef594e908c2121b6d3314b603ba95482b260ca366f8b7d66bbdfebf5a8519ff9d1a82d4e0b2aff1ab58f5e1b0890ae88d837c3df4747aee992099af2"}, @padn={0x1, 0x1, [0x0]}]}, @hopopts={0xff, 0x0, '\x00', [@enc_lim={0x4, 0x1, 0x4}]}, @hopopts={0x32, 0x0, '\x00', [@jumbo={0xc2, 0x4, 0x7feb3b1a}]}, @fragment={0x67, 0x0, 0x4, 0x0, 0x0, 0x13, 0x66}], @icmpv6=@time_exceed={0x3, 0x0, 0x0, 0x9, '\x00', {0xd, 0x6, "6714a3", 0xaa03, 0x4, 0x2, @rand_addr="3bcad557a546709bb0b27eed93186f77", @loopback, [@fragment={0xf0, 0x0, 0x5d, 0x1, 0x0, 0x5, 0x66}], "120edb3b768ebf6d471ef364d35cdef1d2ea2baeeb609eeff34fdb9db8e21713b8f0a52eb63fb11e9ba9f6ecc727098c53a56b952403702623cabd81d01125cfb88ff46c90006e093685d3c0a474a9ec238b7c8ed9f69994e4f430988fd62d5a7f1d8714cfa8a67f787d622f481e26c3e709e8fe8e524bc9420f1668f1c2a72295af78fbc9d84b4f14f14de784"}}}}}}}) syz_execute_func(&(0x7f0000000300)="4c9966f02181001000000f769315000000c4016568636546d939c40203f6dcc4212f10ffc461f4c6a8e20000001fc44129e33642e5fe") syz_extract_tcp_res(&(0x7f0000000340), 0x773c, 0x0) syz_open_pts() csource_test.go:119: 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 #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 int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } 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_iface); 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 lladdr %s", tun_iface, local_mac); char local_ipv4[sizeof(LOCAL_IPV4)]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id); execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4); char remote_mac[sizeof(REMOTE_MAC)]; char remote_ipv4[sizeof(REMOTE_IPV4)]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC); snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id); execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac); char local_ipv6[sizeof(LOCAL_IPV6)]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id); execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6); char remote_ipv6[sizeof(REMOTE_IPV6)]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id); execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac); } static long syz_emit_ethernet(volatile long a0, volatile long a1) { if (tunfd < 0) return (uintptr_t)-1; size_t length = a0; const char* data = (char*)a1; return write(tunfd, data, length); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; exit(1); } return rv; } struct tcp_resources { uint32_t seq; uint32_t ack; }; static long syz_extract_tcp_res(volatile long a0, volatile long a1, volatile long a2) { if (tunfd < 0) return (uintptr_t)-1; char data[1000]; int rv = read_tun(&data[0], sizeof(data)); if (rv == -1) return (uintptr_t)-1; size_t length = rv; if (length < sizeof(struct ether_header)) return (uintptr_t)-1; struct ether_header* ethhdr = (struct ether_header*)&data[0]; struct tcphdr* tcphdr = 0; if (ethhdr->ether_type == htons(ETHERTYPE_IP)) { if (length < sizeof(struct ether_header) + sizeof(struct ip)) return (uintptr_t)-1; struct ip* iphdr = (struct ip*)&data[sizeof(struct ether_header)]; if (iphdr->ip_p != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + iphdr->ip_hl * 4 + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + iphdr->ip_hl * 4]; } else { if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr)) return (uintptr_t)-1; struct ip6_hdr* ipv6hdr = (struct ip6_hdr*)&data[sizeof(struct ether_header)]; if (ipv6hdr->ip6_nxt != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + sizeof(struct ip6_hdr)]; } struct tcp_resources* res = (struct tcp_resources*)a0; res->seq = htonl(ntohl(tcphdr->th_seq) + (uint32_t)a1); res->ack = htonl(ntohl(tcphdr->th_ack) + (uint32_t)a2); return 0; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); initialize_tun(procid); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x7fff; inject_fault(1); syscall(SYS_ioctl, -1, 0x80044279ul, 0x20000000ul); break; case 1: syscall(SYS_ioctl, -1, 0x4004427cul, 0x20000040ul); break; case 2: memcpy((void*)0x20000080, "/dev/pf\000", 8); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x80ul, 0ul); if (res != -1) r[0] = res; break; case 3: *(uint16_t*)0x200000c0 = 0x100; *(uint16_t*)0x200000c2 = 8; *(uint16_t*)0x200000c4 = 6; *(uint16_t*)0x200000c6 = 9; syscall(SYS_ioctl, r[0], 0x80087467ul, 0x200000c0ul); break; case 4: syscall(SYS_ioctl, r[0], 0x4020426bul, 0x20000100ul); break; case 5: res = syscall(SYS_socket, 0x18ul, 0x4000ul, 0); if (res != -1) r[1] = res; break; case 6: memcpy((void*)0x20000140, "\x0b\x61\x99\x93\x30\x40\x52\x0d\x3a\x2a\x08\xe1\xf7\xb4\xb3\x84\x69\x4f\x80\xcd\xb5\xc2\xeb\x41\xf1\xd8\x82\xda\xbf\x02\xc6\x2b\x69\x32\xb0\x37\x24\xa6\xcf\xc9\x58\x44\x82\xd8\xf5\xe1\x80\x49\xfb\x7c\x5f\xc7\xd2\xc0\x99\x8c\x5c\x66\x1c\x02\x03\xd6\xfc\x0a\x98\x16\x56\x0f\x54\xd6\x20\x68\x71\x33\x16\x58\xf5\x79\x42\x99\x07\x04\x9e\xf1\x37\x9e\xa2\x46\xf6\x32\x8a\x95\x08\x15\xf3\xe2\x00\x0f\xcd\x3a\x76\xc2\x85\xb2\x4a\x38\xbc\x3f\x74\x57\x48\x9e\x91\x19\x7a\xe8\x93\x21\xe1\x9d\x43\x97\x7f\x61\xb4\x41\xe2\xcb\xcf\xf6\x74\x4d\x13\xb7\xcd\x20\x53\xbe\x56\xd9\x4a\xa4\x3c\x85\xe6\x9d\x85\x6f\x86\x15\x23\xc3\xc5\x86\x5f\x18\x78\x30\xd3\x8b\x32\x7f\xc9\x05\x89\x8b\x77\xcf\x49\x10\xea\x06\x56\xc5\xf4\x38\xdf\xf6\x11\x2c\xb2\x50\x0a\x1b\x69\x9e\x64\xea\x9f\x59\x47\x39\xfd\xcd\x40\xe9\x24\x19\x82\x15\xcf\x71\x85\xb2\x5a\xcb\x21\x20\x45\xd6\x59\x7e\x41\x81\xcf\xa3\x82\x3c\x39\x2c\x02\xf5\xb3\xed\x34\x14\xb4\x3b\xb8\x60\x92\xfb\x8b\xb2\x92\x24\xc9\xfe\x20\xb3\x50\x62\x7e\x0f\x21\x28\x24\xa3\x99\xb8\xc7\x4b\x61", 253); syscall(SYS_pwrite, r[1], 0x20000140ul, 0xfdul, 0ul, 1ul); break; case 7: *(uint32_t*)0x20000240 = 0xf1ae537; syscall(SYS_ioctl, r[0], 0x8004741bul, 0x20000240ul); break; case 8: res = syscall(SYS_dup2, r[1], r[1]); if (res != -1) r[2] = res; break; case 9: syscall(SYS_ioctl, r[2], 0x20004269ul, 0); break; case 10: memset((void*)0x20000000, 0, 6); memset((void*)0x20000006, 255, 6); *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\xfd\xb6\xcf", 3); *(uint16_t*)0x20000012 = htobe16(0x2b5); *(uint8_t*)0x20000014 = 0; *(uint8_t*)0x20000015 = 0x40; memcpy((void*)0x20000016, "\xa7\xc9\xeb\xf4\xac\x23\x08\x52\x46\x6c\xe7\xf4\x60\x4d\x70\xa9", 16); *(uint64_t*)0x20000026 = htobe64(0); *(uint64_t*)0x2000002e = htobe64(1); *(uint8_t*)0x20000036 = 0x88; *(uint8_t*)0x20000037 = 0; *(uint8_t*)0x20000038 = 0x3f; STORE_BY_BITMASK(uint8_t, , 0x20000039, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000039, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000039, 1, 3, 5); *(uint32_t*)0x2000003a = 0x65; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 6; STORE_BY_BITMASK(uint8_t, , 0x20000041, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000041, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000041, 3, 3, 5); *(uint32_t*)0x20000042 = 0x65; *(uint8_t*)0x20000046 = 8; *(uint8_t*)0x20000047 = 4; memset((void*)0x20000048, 0, 6); *(uint8_t*)0x2000004e = 0; *(uint8_t*)0x2000004f = 1; *(uint8_t*)0x20000050 = 0; *(uint8_t*)0x20000051 = 0xc2; *(uint8_t*)0x20000052 = 4; *(uint32_t*)0x20000053 = htobe32(0); *(uint8_t*)0x20000057 = 0; *(uint8_t*)0x20000058 = 1; *(uint8_t*)0x20000059 = 0; *(uint8_t*)0x2000005a = 0xc2; *(uint8_t*)0x2000005b = 4; *(uint32_t*)0x2000005c = htobe32(0x7fff); *(uint8_t*)0x20000060 = 4; *(uint8_t*)0x20000061 = 1; *(uint8_t*)0x20000062 = 1; *(uint8_t*)0x20000063 = 5; *(uint8_t*)0x20000064 = 2; *(uint16_t*)0x20000065 = htobe16(0x7f); *(uint8_t*)0x20000067 = 0xc2; *(uint8_t*)0x20000068 = 4; *(uint32_t*)0x20000069 = htobe32(0xff); *(uint8_t*)0x2000006d = 1; *(uint8_t*)0x2000006e = 2; *(uint8_t*)0x2000006f = 0; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000076 = -1; *(uint8_t*)0x20000077 = 0x2f; memset((void*)0x20000078, 0, 6); *(uint8_t*)0x2000007e = 0x7f; *(uint8_t*)0x2000007f = 0xc3; memcpy((void*)0x20000080, "\xa2\x86\x0e\x17\x7e\x39\x51\xac\x9a\x2d\xdb\xba\x86\x4c\xdf\xe7\x80\x9d\x7c\x7f\x5e\xc8\xd3\xd0\x2c\x15\x96\x14\x5f\x31\xb1\x3a\xaf\x0b\x04\x1b\x58\x7d\x0d\xcd\xfe\x86\x1c\xce\x1c\x10\xc3\x1b\x97\x2a\x5b\x62\x02\x4f\x50\xa2\xfe\xbc\xbe\x28\xeb\x40\x5e\x5f\xcb\x15\xb1\xc4\x82\x56\x44\x67\x00\x9f\x89\x6f\x2f\x81\xca\x40\xdb\x01\x32\x79\x8f\xaa\x82\xdd\x54\xbc\xb7\x16\x7d\x08\xed\xc8\x6c\x67\xc3\x65\x18\xb6\x02\x5e\x51\x83\xeb\xc8\xaa\x1c\xf9\xb4\x34\xb1\x0e\x01\xb9\xd3\x38\xb5\x07\x7f\x83\x2c\x77\x46\x7d\x18\xda\x55\xee\xf3\x80\xee\xb0\xa5\x38\x73\xca\xc9\xa6\xe7\x8a\x9f\x3f\x94\x84\x1b\x7d\xc1\x68\x28\x96\x13\x21\x01\xf3\xf6\xf1\xb8\x50\x67\xd6\x22\x1a\x8b\x29\x7e\xf8\xc6\x3e\xf3\x17\x7e\x3b\x26\xe2\xb8\x70\xff\xca\xce\xc9\x52\x61\x5c\x25\x9c\xe4\xc2\x0d\x4f\x71\xeb\xcd", 195); *(uint8_t*)0x20000143 = 5; *(uint8_t*)0x20000144 = 2; *(uint16_t*)0x20000145 = htobe16(3); *(uint8_t*)0x20000147 = 1; *(uint8_t*)0x20000148 = 6; *(uint8_t*)0x20000149 = 0; *(uint8_t*)0x2000014a = 0; *(uint8_t*)0x2000014b = 0; *(uint8_t*)0x2000014c = 0; *(uint8_t*)0x2000014d = 0; *(uint8_t*)0x2000014e = 0; *(uint8_t*)0x2000014f = 1; *(uint8_t*)0x20000150 = 6; *(uint8_t*)0x20000151 = 0; *(uint8_t*)0x20000152 = 0; *(uint8_t*)0x20000153 = 0; *(uint8_t*)0x20000154 = 0; *(uint8_t*)0x20000155 = 0; *(uint8_t*)0x20000156 = 0; *(uint8_t*)0x20000157 = -1; *(uint8_t*)0x20000158 = 0x45; memcpy((void*)0x20000159, "\xa8\xc5\x43\xdd\xeb\xe7\x05\xcf\xe1\x47\x75\xe8\xc7\xc2\x9d\xf2\xb8\x93\x6b\x92\x37\x78\xa0\xaf\xa0\xd5\x6f\x41\x8c\x6b\x68\x36\xf8\xd5\x69\xf9\xd4\xb9\x32\x3b\x01\xaf\x68\x57\x76\x36\xd2\x9a\xca\xea\x5d\xb4\xb8\x90\x48\x36\x31\xf2\x96\xab\x36\xa7\xf0\xb4\xc1\xd0\xd0\x0e\x4e", 69); *(uint8_t*)0x2000019e = 0x20; *(uint8_t*)0x2000019f = 0x54; memcpy((void*)0x200001a0, "\x49\xa0\xb1\x86\x29\xaa\x76\xba\xd3\x99\x45\xce\x37\xaa\x36\x21\x27\xde\x1d\x04\x6d\xe6\x76\xb7\xef\x59\x4e\x90\x8c\x21\x21\xb6\xd3\x31\x4b\x60\x3b\xa9\x54\x82\xb2\x60\xca\x36\x6f\x8b\x7d\x66\xbb\xdf\xeb\xf5\xa8\x51\x9f\xf9\xd1\xa8\x2d\x4e\x0b\x2a\xff\x1a\xb5\x8f\x5e\x1b\x08\x90\xae\x88\xd8\x37\xc3\xdf\x47\x47\xae\xe9\x92\x09\x9a\xf2", 84); *(uint8_t*)0x200001f4 = 1; *(uint8_t*)0x200001f5 = 1; *(uint8_t*)0x200001f6 = 0; *(uint8_t*)0x200001fe = -1; *(uint8_t*)0x200001ff = 0; memset((void*)0x20000200, 0, 6); *(uint8_t*)0x20000206 = 4; *(uint8_t*)0x20000207 = 1; *(uint8_t*)0x20000208 = 4; *(uint8_t*)0x2000020e = 0x32; *(uint8_t*)0x2000020f = 0; memset((void*)0x20000210, 0, 6); *(uint8_t*)0x20000216 = 0xc2; *(uint8_t*)0x20000217 = 4; *(uint32_t*)0x20000218 = htobe32(0x7feb3b1a); *(uint8_t*)0x2000021e = 0x67; *(uint8_t*)0x2000021f = 0; *(uint8_t*)0x20000220 = 4; STORE_BY_BITMASK(uint8_t, , 0x20000221, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000221, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000221, 0x13, 3, 5); *(uint32_t*)0x20000222 = 0x66; *(uint8_t*)0x20000226 = 3; *(uint8_t*)0x20000227 = 0; *(uint16_t*)0x20000228 = htobe16(0); *(uint8_t*)0x2000022a = 9; memset((void*)0x2000022b, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x2000022e, 0xd, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000022e, 6, 4, 4); memcpy((void*)0x2000022f, "\x67\x14\xa3", 3); *(uint16_t*)0x20000232 = htobe16(0xaa03); *(uint8_t*)0x20000234 = 4; *(uint8_t*)0x20000235 = 2; memcpy((void*)0x20000236, "\x3b\xca\xd5\x57\xa5\x46\x70\x9b\xb0\xb2\x7e\xed\x93\x18\x6f\x77", 16); *(uint64_t*)0x20000246 = htobe64(0); *(uint64_t*)0x2000024e = htobe64(1); *(uint8_t*)0x20000256 = 0xf0; *(uint8_t*)0x20000257 = 0; *(uint8_t*)0x20000258 = 0x5d; STORE_BY_BITMASK(uint8_t, , 0x20000259, 1, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000259, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000259, 5, 3, 5); *(uint32_t*)0x2000025a = 0x66; memcpy((void*)0x2000025e, "\x12\x0e\xdb\x3b\x76\x8e\xbf\x6d\x47\x1e\xf3\x64\xd3\x5c\xde\xf1\xd2\xea\x2b\xae\xeb\x60\x9e\xef\xf3\x4f\xdb\x9d\xb8\xe2\x17\x13\xb8\xf0\xa5\x2e\xb6\x3f\xb1\x1e\x9b\xa9\xf6\xec\xc7\x27\x09\x8c\x53\xa5\x6b\x95\x24\x03\x70\x26\x23\xca\xbd\x81\xd0\x11\x25\xcf\xb8\x8f\xf4\x6c\x90\x00\x6e\x09\x36\x85\xd3\xc0\xa4\x74\xa9\xec\x23\x8b\x7c\x8e\xd9\xf6\x99\x94\xe4\xf4\x30\x98\x8f\xd6\x2d\x5a\x7f\x1d\x87\x14\xcf\xa8\xa6\x7f\x78\x7d\x62\x2f\x48\x1e\x26\xc3\xe7\x09\xe8\xfe\x8e\x52\x4b\xc9\x42\x0f\x16\x68\xf1\xc2\xa7\x22\x95\xaf\x78\xfb\xc9\xd8\x4b\x4f\x14\xf1\x4d\xe7\x84", 141); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000016, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000026, 16); uint32_t csum_1_chunk_2 = 0xc5000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x3a000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000226, 197); *(uint16_t*)0x20000228 = csum_inet_digest(&csum_1); syz_emit_ethernet(0x2eb, 0x20000000); break; case 11: memcpy((void*)0x20000300, "\x4c\x99\x66\xf0\x21\x81\x00\x10\x00\x00\x0f\x76\x93\x15\x00\x00\x00\xc4\x01\x65\x68\x63\x65\x46\xd9\x39\xc4\x02\x03\xf6\xdc\xc4\x21\x2f\x10\xff\xc4\x61\xf4\xc6\xa8\xe2\x00\x00\x00\x1f\xc4\x41\x29\xe3\x36\x42\xe5\xfe", 54); syz_execute_func(0x20000300); break; case 12: syz_extract_tcp_res(0x20000340, 0x773c, 0); break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :506:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :504:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3714457025 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/7 (1.78s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/5 (0.64s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/2 (0.59s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/3 (0.57s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/1 (0.55s) csource_test.go:116: FAIL FAIL github.com/google/syzkaller/pkg/csource 15.663s ok github.com/google/syzkaller/pkg/db (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ok github.com/google/syzkaller/pkg/email (cached) ? github.com/google/syzkaller/pkg/gce [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ok github.com/google/syzkaller/pkg/host (cached) ? github.com/google/syzkaller/pkg/html [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ok github.com/google/syzkaller/pkg/instance (cached) ok github.com/google/syzkaller/pkg/ipc (cached) ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/pkg/kconfig 0.329s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig (cached) ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report (cached) ok github.com/google/syzkaller/pkg/repro (cached) ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest (cached) ok github.com/google/syzkaller/pkg/serializer (cached) ? github.com/google/syzkaller/pkg/signal [no test files] ok github.com/google/syzkaller/pkg/symbolizer (cached) ok github.com/google/syzkaller/pkg/tool (cached) ok github.com/google/syzkaller/pkg/vcs (cached) ok github.com/google/syzkaller/prog (cached) ok github.com/google/syzkaller/prog/test (cached) ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/darwin/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ok github.com/google/syzkaller/sys/linux (cached) ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ok github.com/google/syzkaller/sys/openbsd (cached) ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ok github.com/google/syzkaller/syz-ci (cached) ok github.com/google/syzkaller/syz-fuzzer (cached) ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager (cached) ? github.com/google/syzkaller/syz-runner [no test files] ok github.com/google/syzkaller/syz-verifier 1.130s ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ok github.com/google/syzkaller/tools/syz-kconf (cached) ok github.com/google/syzkaller/tools/syz-linter (cached) ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/parser (cached) ok github.com/google/syzkaller/tools/syz-trace2syz/proggen (cached) ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ok github.com/google/syzkaller/vm (cached) ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ok github.com/google/syzkaller/vm/isolated (cached) ? github.com/google/syzkaller/vm/kvm [no test files] ? github.com/google/syzkaller/vm/odroid [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ok github.com/google/syzkaller/vm/vmimpl (cached) ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL