ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 0.507s ok github.com/google/syzkaller/pkg/ast 4.458s ok github.com/google/syzkaller/pkg/bisect (cached) ok github.com/google/syzkaller/pkg/build (cached) ok github.com/google/syzkaller/pkg/compiler 11.753s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/cover (cached) ? github.com/google/syzkaller/pkg/cover/backend [no test files] --- FAIL: TestGenerate (5.68s) --- FAIL: TestGenerate/openbsd/amd64 (0.22s) csource_test.go:67: seed=1609073999633190814 --- FAIL: TestGenerate/openbsd/amd64/0 (3.43s) csource_test.go:123: opts: {Threaded:false Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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[2] = {0xffffffffffffffff, 0x0}; void execute_one(void) { intptr_t res = 0; *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); syz_open_pts(); *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); syscall(SYS_socket, 1ul, 3ul, 8); *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); syz_open_pts(); } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); use_temporary_dir(); do_sandbox_none(); return 0; } :193:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :191:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor117488715 -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 (3.53s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox: Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); use_temporary_dir(); loop(); return 0; } :305:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :303:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor204240053 -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 (3.00s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:false HandleSegv:false Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void 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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); do_sandbox_none(); return 0; } :278:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :276:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor007329465 -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 (4.24s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:10 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); use_temporary_dir(); do_sandbox_none(); return 0; } :330:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :328:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor214385966 -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/12 (4.14s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); use_temporary_dir(); do_sandbox_none(); return 0; } :332:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :330:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor882251842 -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 (4.45s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:4 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :332:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :330:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor055310992 -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 (4.12s) csource_test.go:123: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:2 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :342:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :340:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor014994771 -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/13 (4.08s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:true} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; res = syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); break; case 1: res = syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; res = syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: res = syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); break; case 5: res = syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); break; case 6: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); res = syscall(SYS_lchown, 0x20001100ul, r[1], -1); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: res = syscall(SYS_socket, 1ul, 3ul, 8); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); (void)res; break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); res = -1; errno = EFAULT; res = syz_execute_func(0x200000c0); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; case 12: (void)res; break; case 13: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=13 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); use_temporary_dir(); do_sandbox_none(); return 0; } :331:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :329:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor132580548 -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/5 (4.59s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:1 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000040 = 8; syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: *(uint64_t*)0x20001080 = 1; *(uint64_t*)0x20001088 = 0xffffffff; syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: syz_open_pts(); break; case 7: *(uint32_t*)0x20001180 = 0xc; res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) r[1] = *(uint32_t*)0x20001144; break; case 8: memcpy((void*)0x20001100, "./file0\000", 8); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = -1; *(uint8_t*)0x20000007 = -1; *(uint8_t*)0x20000008 = -1; *(uint8_t*)0x20000009 = -1; *(uint8_t*)0x2000000a = -1; *(uint8_t*)0x2000000b = -1; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x3d\x89\x77", 3); *(uint16_t*)0x20000012 = htobe16(0x78); *(uint8_t*)0x20000014 = 0x30; *(uint8_t*)0x20000015 = 3; *(uint8_t*)0x20000016 = -1; *(uint8_t*)0x20000017 = 2; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 1; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = -1; *(uint8_t*)0x20000031 = -1; *(uint32_t*)0x20000032 = htobe32(0xe0000001); *(uint8_t*)0x20000036 = 5; *(uint8_t*)0x20000037 = 8; *(uint8_t*)0x20000038 = 0; *(uint8_t*)0x20000039 = 1; *(uint32_t*)0x2000003a = 0; *(uint8_t*)0x2000003e = 0; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 0; *(uint8_t*)0x20000041 = 0; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16); memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16); *(uint8_t*)0x2000006e = -1; *(uint8_t*)0x2000006f = 2; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 1; *(uint8_t*)0x2000007e = 3; *(uint8_t*)0x2000007f = 0; *(uint8_t*)0x20000080 = 0xe3; STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2); STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5); *(uint32_t*)0x20000082 = 0x66; *(uint8_t*)0x20000086 = 2; *(uint8_t*)0x20000087 = 0; *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 1; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000096 = 0x83; *(uint8_t*)0x20000097 = 0; *(uint16_t*)0x20000098 = htobe16(0); *(uint16_t*)0x2000009a = htobe16(0x1e1); *(uint16_t*)0x2000009c = 0x66c2; *(uint8_t*)0x2000009e = 0; *(uint8_t*)0x2000009f = 0; *(uint8_t*)0x200000a0 = 0; *(uint8_t*)0x200000a1 = 0; *(uint8_t*)0x200000a2 = 0; *(uint8_t*)0x200000a3 = 0; *(uint8_t*)0x200000a4 = 0; *(uint8_t*)0x200000a5 = 0; *(uint8_t*)0x200000a6 = 0; *(uint8_t*)0x200000a7 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = -1; *(uint32_t*)0x200000aa = htobe32(0xe0000002); 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 = 0x18000000; 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*)0x20000096, 24); *(uint16_t*)0x20000098 = csum_inet_digest(&csum_1); break; case 11: memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56); syz_execute_func(0x200000c0); break; case 12: break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); use_temporary_dir(); do_sandbox_none(); return 0; } :330:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :328:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor458406575 -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 (2.87s) csource_test.go:121: --- FAIL: TestGenerate/openbsd/amd64/11 (2.88s) csource_test.go:123: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Sandbox:none Fault:false FaultCall:0 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:true HandleSegv:true Repro:false Trace:false} program: getsockopt$sock_linger(0xffffffffffffffff, 0xffff, 0x80, &(0x7f0000000000), &(0x7f0000000040)=0x8) read(0xffffffffffffffff, &(0x7f0000000080)=""/4096, 0x1000) r0 = socket$inet(0x2, 0x5, 0x0) setsockopt$sock_timeval(r0, 0xffff, 0x1005, &(0x7f0000001080)={0x1, 0xffffffff}, 0x10) ioctl$FIONREAD(0xffffffffffffff9c, 0x4004667f, &(0x7f00000010c0)) shmat(0x0, &(0x7f0000ff9000/0x4000)=nil, 0x2000) syz_open_pts() getsockopt$sock_cred(r0, 0xffff, 0x1022, &(0x7f0000001140)={0x0, 0x0}, &(0x7f0000001180)=0xc) lchown(&(0x7f0000001100)='./file0\x00', r1, 0xffffffffffffffff) socket(0x1, 0x3, 0x8) syz_emit_ethernet(0xae, &(0x7f0000000000)={@broadcast, @broadcast, [], {@ipv6={0x86dd, {0xe, 0x6, "3d8977", 0x78, 0x30, 0x3, @mcast2, @ipv4={[], [], @multicast1}, {[@routing={0x5, 0x8, 0x0, 0x1, 0x0, [@empty, @rand_addr="d8f78bacbd4c79fcd8bbd7888d5a55a2", @rand_addr="461b813c49d15d01a883cbc640d32686", @mcast2]}, @fragment={0x3, 0x0, 0xe3, 0x0, 0x0, 0x3, 0x66}, @hopopts={0x2, 0x0, [], [@pad1]}], @icmpv6=@mld={0x83, 0x0, 0x0, 0x1e1, 0x66c2, @ipv4={[], [], @multicast2}}}}}}}) syz_execute_func(&(0x7f00000000c0)="0f3803c90f5568ab660f50ce66440fdadc660f38f648e02e0ff9d9c4c1f910bd5d000000c4210571f0eb0fbc8ab2f80599c402459364ac03") syz_extract_tcp_res(&(0x7f0000000100), 0x1ff, 0x7eb4) syz_open_pts() csource_test.go:124: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) ({ int ok = 1; __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); if (_setjmp(segv_env) == 0) { __VA_ARGS__; } else ok = 0; __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); ok; }) static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #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, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: NONFAILING(*(uint32_t*)0x20000040 = 8); syscall(SYS_getsockopt, -1, 0xffff, 0x80, 0x20000000ul, 0x20000040ul); break; case 1: syscall(SYS_read, -1, 0x20000080ul, 0x1000ul); break; case 2: res = syscall(SYS_socket, 2ul, 5ul, 0); if (res != -1) r[0] = res; break; case 3: NONFAILING(*(uint64_t*)0x20001080 = 1); NONFAILING(*(uint64_t*)0x20001088 = 0xffffffff); syscall(SYS_setsockopt, r[0], 0xffff, 0x1005, 0x20001080ul, 0x10ul); break; case 4: syscall(SYS_ioctl, 0xffffff9c, 0x4004667ful, 0x200010c0ul); break; case 5: syscall(SYS_shmat, 0, 0x20ff9000ul, 0x2000ul); break; case 6: NONFAILING(syz_open_pts()); break; case 7: NONFAILING(*(uint32_t*)0x20001180 = 0xc); res = syscall(SYS_getsockopt, r[0], 0xffff, 0x1022, 0x20001140ul, 0x20001180ul); if (res != -1) NONFAILING(r[1] = *(uint32_t*)0x20001144); break; case 8: NONFAILING(memcpy((void*)0x20001100, "./file0\000", 8)); syscall(SYS_lchown, 0x20001100ul, r[1], -1); break; case 9: syscall(SYS_socket, 1ul, 3ul, 8); break; case 10: NONFAILING(*(uint8_t*)0x20000000 = -1); NONFAILING(*(uint8_t*)0x20000001 = -1); NONFAILING(*(uint8_t*)0x20000002 = -1); NONFAILING(*(uint8_t*)0x20000003 = -1); NONFAILING(*(uint8_t*)0x20000004 = -1); NONFAILING(*(uint8_t*)0x20000005 = -1); NONFAILING(*(uint8_t*)0x20000006 = -1); NONFAILING(*(uint8_t*)0x20000007 = -1); NONFAILING(*(uint8_t*)0x20000008 = -1); NONFAILING(*(uint8_t*)0x20000009 = -1); NONFAILING(*(uint8_t*)0x2000000a = -1); NONFAILING(*(uint8_t*)0x2000000b = -1); NONFAILING(*(uint16_t*)0x2000000c = htobe16(0x86dd)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000e, 0xe, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000e, 6, 4, 4)); NONFAILING(memcpy((void*)0x2000000f, "\x3d\x89\x77", 3)); NONFAILING(*(uint16_t*)0x20000012 = htobe16(0x78)); NONFAILING(*(uint8_t*)0x20000014 = 0x30); NONFAILING(*(uint8_t*)0x20000015 = 3); NONFAILING(*(uint8_t*)0x20000016 = -1); NONFAILING(*(uint8_t*)0x20000017 = 2); NONFAILING(*(uint8_t*)0x20000018 = 0); NONFAILING(*(uint8_t*)0x20000019 = 0); NONFAILING(*(uint8_t*)0x2000001a = 0); NONFAILING(*(uint8_t*)0x2000001b = 0); NONFAILING(*(uint8_t*)0x2000001c = 0); NONFAILING(*(uint8_t*)0x2000001d = 0); NONFAILING(*(uint8_t*)0x2000001e = 0); NONFAILING(*(uint8_t*)0x2000001f = 0); NONFAILING(*(uint8_t*)0x20000020 = 0); NONFAILING(*(uint8_t*)0x20000021 = 0); NONFAILING(*(uint8_t*)0x20000022 = 0); NONFAILING(*(uint8_t*)0x20000023 = 0); NONFAILING(*(uint8_t*)0x20000024 = 0); NONFAILING(*(uint8_t*)0x20000025 = 1); NONFAILING(*(uint8_t*)0x20000026 = 0); NONFAILING(*(uint8_t*)0x20000027 = 0); NONFAILING(*(uint8_t*)0x20000028 = 0); NONFAILING(*(uint8_t*)0x20000029 = 0); NONFAILING(*(uint8_t*)0x2000002a = 0); NONFAILING(*(uint8_t*)0x2000002b = 0); NONFAILING(*(uint8_t*)0x2000002c = 0); NONFAILING(*(uint8_t*)0x2000002d = 0); NONFAILING(*(uint8_t*)0x2000002e = 0); NONFAILING(*(uint8_t*)0x2000002f = 0); NONFAILING(*(uint8_t*)0x20000030 = -1); NONFAILING(*(uint8_t*)0x20000031 = -1); NONFAILING(*(uint32_t*)0x20000032 = htobe32(0xe0000001)); NONFAILING(*(uint8_t*)0x20000036 = 5); NONFAILING(*(uint8_t*)0x20000037 = 8); NONFAILING(*(uint8_t*)0x20000038 = 0); NONFAILING(*(uint8_t*)0x20000039 = 1); NONFAILING(*(uint32_t*)0x2000003a = 0); NONFAILING(*(uint8_t*)0x2000003e = 0); NONFAILING(*(uint8_t*)0x2000003f = 0); NONFAILING(*(uint8_t*)0x20000040 = 0); NONFAILING(*(uint8_t*)0x20000041 = 0); NONFAILING(*(uint8_t*)0x20000042 = 0); NONFAILING(*(uint8_t*)0x20000043 = 0); NONFAILING(*(uint8_t*)0x20000044 = 0); NONFAILING(*(uint8_t*)0x20000045 = 0); NONFAILING(*(uint8_t*)0x20000046 = 0); NONFAILING(*(uint8_t*)0x20000047 = 0); NONFAILING(*(uint8_t*)0x20000048 = 0); NONFAILING(*(uint8_t*)0x20000049 = 0); NONFAILING(*(uint8_t*)0x2000004a = 0); NONFAILING(*(uint8_t*)0x2000004b = 0); NONFAILING(*(uint8_t*)0x2000004c = 0); NONFAILING(*(uint8_t*)0x2000004d = 0); NONFAILING(memcpy((void*)0x2000004e, "\xd8\xf7\x8b\xac\xbd\x4c\x79\xfc\xd8\xbb\xd7\x88\x8d\x5a\x55\xa2", 16)); NONFAILING(memcpy((void*)0x2000005e, "\x46\x1b\x81\x3c\x49\xd1\x5d\x01\xa8\x83\xcb\xc6\x40\xd3\x26\x86", 16)); NONFAILING(*(uint8_t*)0x2000006e = -1); NONFAILING(*(uint8_t*)0x2000006f = 2); NONFAILING(*(uint8_t*)0x20000070 = 0); NONFAILING(*(uint8_t*)0x20000071 = 0); NONFAILING(*(uint8_t*)0x20000072 = 0); NONFAILING(*(uint8_t*)0x20000073 = 0); NONFAILING(*(uint8_t*)0x20000074 = 0); NONFAILING(*(uint8_t*)0x20000075 = 0); NONFAILING(*(uint8_t*)0x20000076 = 0); NONFAILING(*(uint8_t*)0x20000077 = 0); NONFAILING(*(uint8_t*)0x20000078 = 0); NONFAILING(*(uint8_t*)0x20000079 = 0); NONFAILING(*(uint8_t*)0x2000007a = 0); NONFAILING(*(uint8_t*)0x2000007b = 0); NONFAILING(*(uint8_t*)0x2000007c = 0); NONFAILING(*(uint8_t*)0x2000007d = 1); NONFAILING(*(uint8_t*)0x2000007e = 3); NONFAILING(*(uint8_t*)0x2000007f = 0); NONFAILING(*(uint8_t*)0x20000080 = 0xe3); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 0, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 1, 2)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x20000081, 3, 3, 5)); NONFAILING(*(uint32_t*)0x20000082 = 0x66); NONFAILING(*(uint8_t*)0x20000086 = 2); NONFAILING(*(uint8_t*)0x20000087 = 0); NONFAILING(*(uint8_t*)0x20000088 = 0); NONFAILING(*(uint8_t*)0x20000089 = 0); NONFAILING(*(uint8_t*)0x2000008a = 0); NONFAILING(*(uint8_t*)0x2000008b = 0); NONFAILING(*(uint8_t*)0x2000008c = 0); NONFAILING(*(uint8_t*)0x2000008d = 0); NONFAILING(*(uint8_t*)0x2000008e = 0); NONFAILING(*(uint8_t*)0x2000008f = 1); NONFAILING(*(uint8_t*)0x20000090 = 0); NONFAILING(*(uint8_t*)0x20000096 = 0x83); NONFAILING(*(uint8_t*)0x20000097 = 0); NONFAILING(*(uint16_t*)0x20000098 = htobe16(0)); NONFAILING(*(uint16_t*)0x2000009a = htobe16(0x1e1)); NONFAILING(*(uint16_t*)0x2000009c = 0x66c2); NONFAILING(*(uint8_t*)0x2000009e = 0); NONFAILING(*(uint8_t*)0x2000009f = 0); NONFAILING(*(uint8_t*)0x200000a0 = 0); NONFAILING(*(uint8_t*)0x200000a1 = 0); NONFAILING(*(uint8_t*)0x200000a2 = 0); NONFAILING(*(uint8_t*)0x200000a3 = 0); NONFAILING(*(uint8_t*)0x200000a4 = 0); NONFAILING(*(uint8_t*)0x200000a5 = 0); NONFAILING(*(uint8_t*)0x200000a6 = 0); NONFAILING(*(uint8_t*)0x200000a7 = 0); NONFAILING(*(uint8_t*)0x200000a8 = -1); NONFAILING(*(uint8_t*)0x200000a9 = -1); NONFAILING(*(uint32_t*)0x200000aa = htobe32(0xe0000002)); struct csum_inet csum_1; csum_inet_init(&csum_1); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x20000016, 16)); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x20000026, 16)); uint32_t csum_1_chunk_2 = 0x18000000; 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); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x20000096, 24)); NONFAILING(*(uint16_t*)0x20000098 = csum_inet_digest(&csum_1)); break; case 11: NONFAILING(memcpy((void*)0x200000c0, "\x0f\x38\x03\xc9\x0f\x55\x68\xab\x66\x0f\x50\xce\x66\x44\x0f\xda\xdc\x66\x0f\x38\xf6\x48\xe0\x2e\x0f\xf9\xd9\xc4\xc1\xf9\x10\xbd\x5d\x00\x00\x00\xc4\x21\x05\x71\xf0\xeb\x0f\xbc\x8a\xb2\xf8\x05\x99\xc4\x02\x45\x93\x64\xac\x03", 56)); NONFAILING(syz_execute_func(0x200000c0)); break; case 12: break; case 13: NONFAILING(syz_open_pts()); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; } :359:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :357:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor130145942 -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/2 (2.94s) csource_test.go:121: --- FAIL: TestGenerate/openbsd/amd64/1 (2.59s) csource_test.go:121: --- FAIL: TestGenerate/openbsd/amd64/8 (2.26s) csource_test.go:121: FAIL FAIL github.com/google/syzkaller/pkg/csource 21.201s 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.287s 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/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/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ? github.com/google/syzkaller/tools/syz-kconf [no test files] ok github.com/google/syzkaller/tools/syz-linter (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