ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/executor 1.402s ok github.com/google/syzkaller/pkg/ast 2.972s ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect 130.099s ok github.com/google/syzkaller/pkg/build 5.775s ok github.com/google/syzkaller/pkg/compiler 26.913s ? github.com/google/syzkaller/pkg/config [no test files] ok github.com/google/syzkaller/pkg/cover 0.539s ok github.com/google/syzkaller/pkg/cover/backend 0.662s --- FAIL: TestGenerate (65.64s) --- FAIL: TestGenerate/openbsd/amd64 (0.79s) csource_test.go:52: seed=1633103715920724717 --- FAIL: TestGenerate/openbsd/amd64/0 (2.15s) csource_test.go:118: opts: {Threaded:false Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #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[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; res = syscall(SYS_getppid); if (res != -1) r[5] = res; *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); syz_open_pts(); } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :175:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :173:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor198743493 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/14 (2.36s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:true LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { fprintf(stderr, "### start\n"); int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; res = syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; res = syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; res = syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); res = -1; errno = EFAULT; res = syz_execute_func(0x20000040); fprintf(stderr, "### call=10 errno=%u\n", res == -1 ? errno : 0); break; case 11: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :313:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :311:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1707748594 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/8 (2.48s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox: Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); loop(); return 0; } :287:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :285:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3128712257 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/10 (2.58s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:true NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static int tunfd = -1; #define MAX_TUN 4 #define TUN_IFACE "tap%d" #define TUN_DEVICE "/dev/tap%d" #define LOCAL_MAC "aa:aa:aa:aa:aa:aa" #define REMOTE_MAC "aa:aa:aa:aa:aa:bb" #define LOCAL_IPV4 "172.20.%d.170" #define REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv = vsnprintf(str, size, format, args); if (rv < 0) exit(1); if ((size_t)rv >= size) exit(1); } static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } #define COMMAND_MAX_LEN 128 #define PATH_PREFIX "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) static void execute_command(bool panic, const char* format, ...) { va_list args; va_start(args, format); char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; memcpy(command, PATH_PREFIX, PATH_PREFIX_LEN); vsnprintf_check(command + PATH_PREFIX_LEN, COMMAND_MAX_LEN, format, args); va_end(args); int rv = system(command); if (rv) { if (panic) exit(1); } } static void initialize_tun(int tun_id) { if (tun_id < 0 || tun_id >= MAX_TUN) exit(1); char tun_device[sizeof(TUN_DEVICE)]; snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id); char tun_iface[sizeof(TUN_IFACE)]; snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id); execute_command(0, "ifconfig %s destroy", tun_iface); tunfd = open(tun_device, O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open %s: errno=%d\n", tun_device, errno); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; char local_mac[sizeof(LOCAL_MAC)]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC); execute_command(1, "ifconfig %s lladdr %s", tun_iface, local_mac); char local_ipv4[sizeof(LOCAL_IPV4)]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id); execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4); char remote_mac[sizeof(REMOTE_MAC)]; char remote_ipv4[sizeof(REMOTE_IPV4)]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC); snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id); execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac); char local_ipv6[sizeof(LOCAL_IPV6)]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id); execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6); char remote_ipv6[sizeof(REMOTE_IPV6)]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id); execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac); } static long syz_emit_ethernet(volatile long a0, volatile long a1) { if (tunfd < 0) return (uintptr_t)-1; size_t length = a0; const char* data = (char*)a1; return write(tunfd, data, length); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; exit(1); } return rv; } struct tcp_resources { uint32_t seq; uint32_t ack; }; static long syz_extract_tcp_res(volatile long a0, volatile long a1, volatile long a2) { if (tunfd < 0) return (uintptr_t)-1; char data[1000]; int rv = read_tun(&data[0], sizeof(data)); if (rv == -1) return (uintptr_t)-1; size_t length = rv; if (length < sizeof(struct ether_header)) return (uintptr_t)-1; struct ether_header* ethhdr = (struct ether_header*)&data[0]; struct tcphdr* tcphdr = 0; if (ethhdr->ether_type == htons(ETHERTYPE_IP)) { if (length < sizeof(struct ether_header) + sizeof(struct ip)) return (uintptr_t)-1; struct ip* iphdr = (struct ip*)&data[sizeof(struct ether_header)]; if (iphdr->ip_p != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + iphdr->ip_hl * 4 + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + iphdr->ip_hl * 4]; } else { if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr)) return (uintptr_t)-1; struct ip6_hdr* ipv6hdr = (struct ip6_hdr*)&data[sizeof(struct ether_header)]; if (ipv6hdr->ip6_nxt != IPPROTO_TCP) return (uintptr_t)-1; if (length < sizeof(struct ether_header) + sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) return (uintptr_t)-1; tcphdr = (struct tcphdr*)&data[sizeof(struct ether_header) + sizeof(struct ip6_hdr)]; } struct tcp_resources* res = (struct tcp_resources*)a0; res->seq = htonl(ntohl(tcphdr->th_seq) + (uint32_t)a1); res->ack = htonl(ntohl(tcphdr->th_ack) + (uint32_t)a2); return 0; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); initialize_tun(procid); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memset((void*)0x20000000, 170, 5); *(uint8_t*)0x20000005 = 0xaa; memset((void*)0x20000006, 170, 5); *(uint8_t*)0x2000000b = 0xbb; *(uint16_t*)0x2000000c = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, , 0x2000000e, 4, 0, 3); STORE_BY_BITMASK(uint16_t, , 0x2000000e, 0, 3, 1); STORE_BY_BITMASK(uint16_t, , 0x2000000e, 0, 4, 12); *(uint16_t*)0x20000010 = htobe16(0x806); *(uint16_t*)0x20000012 = htobe16(1); *(uint16_t*)0x20000014 = htobe16(0x800); *(uint8_t*)0x20000016 = 6; *(uint8_t*)0x20000017 = 4; *(uint16_t*)0x20000018 = htobe16(1); memset((void*)0x2000001a, 0, 6); *(uint32_t*)0x20000020 = htobe32(-1); memcpy((void*)0x20000024, "\x61\x20\x6f\x49\xe4\xef", 6); *(uint8_t*)0x2000002a = 0xac; *(uint8_t*)0x2000002b = 0x14; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0xbb; syz_emit_ethernet(0x2e, 0x20000000); break; case 11: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 12: syz_extract_tcp_res(0x20000080, 8, 1); break; case 13: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :479:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :477:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4273053689 -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.91s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:setuid Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, WUNTRACED) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_setuid(void) { int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); char pwbuf[1024]; struct passwd *pw, pwres; if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw) exit(1); if (setgroups(0, NULL)) exit(1); if (setgid(pw->pw_gid)) exit(1); if (setuid(pw->pw_uid)) exit(1); loop(); exit(1); } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_setuid(); return 0; } :335:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :333:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1803174225 -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 (3.19s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :314:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :312:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1607631355 -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 (2.98s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:10 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #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, 500); 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 < 15000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :312:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :310:3: note: previous statement is here if (current_time_ms() - start < 15000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1159842871 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/15 (4.81s) csource_test.go:118: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:2 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; int collide = 0; again: for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23 + procid*4; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :324:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :322:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4242010373 -DGOOS_openbsd=1 -DGOARCH_amd64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -static -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384] --- FAIL: TestGenerate/openbsd/amd64/11 (5.26s) csource_test.go:118: opts: {Threaded:true Collide:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:false HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #define __syscall syscall static uintptr_t syz_open_pts(void) { int master, slave; if (openpty(&master, &slave, NULL, NULL, NULL) == -1) return -1; if (dup2(master, master + 100) != -1) close(master); return slave; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); do_sandbox_none(); return 0; } :260:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :258:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3780535844 -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.96s) csource_test.go:118: opts: {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0}} program: r0 = openat$klog(0xffffffffffffff9c, &(0x7f0000000380), 0x20, 0x0) (fail_nth: 1) r1 = dup(0xffffffffffffffff) r2 = openat$wsdisplay(0xffffffffffffff9c, &(0x7f00000003c0), 0x2, 0x0) pipe(&(0x7f0000000400)={0xffffffffffffffff, 0xffffffffffffffff}) r4 = openat$zero(0xffffffffffffff9c, &(0x7f0000000440), 0x100, 0x0) r5 = getppid() sendmsg$unix(0xffffffffffffffff, &(0x7f0000000540)={&(0x7f0000000000)=@abs={0x1, 0x0, 0x3}, 0x8, &(0x7f0000000340)=[{&(0x7f0000000040)="d9bf367b50f3c3785cf9017d203887b8cbd7edbf0c513de7caced14241880499bc2467d899710a738bb00036ea71483b020fd85fd325d56f0cb0bea0cb3cb3a1c74547b0a6532292ff38c598bf9069ca7ed5aa7c500c2dc7b34c23212160450a282d60e14a89e8a2e6345d717f0c24ce9cbaba7ff583c61aae36b0bd68f99a776cc3f158e24c1d430a5d1a1d8ef845b2952d1107cacda72bb8c88c78e60add1d7ae7", 0xa2}, {&(0x7f0000000100)="37b0cc3fd8a49c87cd19cdd3018bee995c2ac8f832d656985b13320ec9766985d7eba8605bfcc434680637f19a7a587f8879fdfc85a16bddcb5dc0d96885b0fe36b5b59db3a66bd3844415e8f85db38f0344f9bb776cd523181888ea0f3736ac9584f3f197d36bea8214fbbf712160dbe0ab2d89264d65dfa2591b901e45c9a3278aea7869723d2127d1f83797f2fd9365738d0c2cae613cd19e60f6dd3480bdb48c6a4929c0a07d2e7c2dcfd71478c8c42588daa66ad59ed976e2a9bd0474d8fd5d5ae3d270358be325e6fdbf9bad1756c70e7a51658a91975bd6", 0xdb}, {&(0x7f0000000200)="cf393be600873cc7fab3b2638b6b39b48ac46df9357f00e6b6118bad0fddf7fee9eaaba8e65cb4c9797227d3e958efbadbcd640b1079304ac9818991ca4834fcd9de21da0f3bb9a3cc6577351484ff42ada975cd22d7619dd1617b7c9ce5911bd0733e87b9b39ee05e6d249e98d58791d00e7ca117", 0x75}, {&(0x7f0000000280)="9988236f6d3c6217b8df8e7040147c2a2804be6ccf57eeee9befd0760666ca416fb366f9d0c1579c0c3b6b3150df38d8a56c72c109696dfc7eb2ddb22ff4b23e22aab7014b0830e7220c1f4a5eea58672fe177193ef78e647d7c6f89636c248985dfb4d055ed0552646b8c3d8182db238a0d269241ba967c10c615e42729b414b2be8f7de20b65", 0x87}], 0x4, &(0x7f0000000480)=[@cred={0x20, 0xffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}, @rights={0x20, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r0, r1]}, @rights={0x30, 0xffff, 0x1, [0xffffffffffffff9c, 0xffffffffffffff9c, r2, r3, 0xffffffffffffff9c, 0xffffffffffffff9c, r4]}, @cred={0x20}, @cred={0x20, 0xffff, 0x0, r5, 0xffffffffffffffff, 0xffffffffffffffff}], 0xb0, 0x8}, 0x400) r6 = openat$wsmuxmouse(0xffffffffffffff9c, &(0x7f0000000580), 0x80, 0x0) ioctl$KDSETMODE(r6, 0x20004b0a, &(0x7f00000005c0)=0x1) ioctl$WSMUXIO_LIST_DEVICES(r6, 0xc1045763, &(0x7f0000000600)={0x8001, [{0x3, 0x20}, {0x1, 0x18}, {0x3, 0x3}, {0x2, 0x8}, {0x2, 0x7f}, {0x3, 0x7da5}, {0x1, 0x9}, {0x3, 0x43b}, {0x1, 0x8}, {0x1, 0x401}, {0x3, 0x5}, {0x1, 0xdb99}, {0x2, 0x57a}, {0x2, 0x800}, {0x1, 0x7}, {0x3, 0x3}, {0x1, 0x2}, {0x2, 0x2}, {0x3, 0x12}, {0x3, 0x20}, {0x3, 0xffffff66}, {0x2, 0x1000}, {0x1}, {0x0, 0x34fe}, {0x2, 0x6}, {0x1, 0x100}, {0x2, 0x1}, {0x2, 0x2}, {0x3}, {0x3, 0x120000}, {0x3, 0x200}, {0x7a2b23c9b8acdae4, 0x5}]}) syz_emit_ethernet(0x2e, &(0x7f0000000000)={@local, @remote, [{[], {0x8100, 0x4}}], {@arp={0x806, @ether_ipv4={0x1, 0x800, 0x6, 0x4, 0x1, @empty, @broadcast, @random="61206f49e4ef", @remote={0xac, 0x14, 0x0}}}}}) syz_execute_func(&(0x7f0000000040)="3e420f70400006c4c12972e684c441fc11b3001000002edee9cbc421f850d3f0184a00c4017b102528233333d0faf04280309b") syz_extract_tcp_res(&(0x7f0000000080), 0x8, 0x1) syz_open_pts() csource_test.go:119: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void __attribute__((noinline)) remove_dir(const char* dir) { DIR* dp = opendir(dir); if (dp == NULL) { if (errno == EACCES) { if (rmdir(dir)) exit(1); return; } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } if (unlink(filename)) exit(1); } closedir(dp); if (rmdir(dir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #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; int collide = 0; again: for (call = 0; call < 14; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000380, "/dev/klog\000", 10); inject_fault(1); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000380ul, 0x20ul, 0ul); if (res != -1) r[0] = res; break; case 1: res = syscall(SYS_dup, -1); if (res != -1) r[1] = res; break; case 2: memcpy((void*)0x200003c0, "/dev/ttyCcfg\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 2ul, 0ul); if (res != -1) r[2] = res; break; case 3: res = syscall(SYS_pipe, 0x20000400ul); if (res != -1) r[3] = *(uint32_t*)0x20000404; break; case 4: memcpy((void*)0x20000440, "/dev/zero\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000440ul, 0x100ul, 0ul); if (res != -1) r[4] = res; break; case 5: res = syscall(SYS_getppid); if (res != -1) r[5] = res; break; case 6: *(uint64_t*)0x20000540 = 0x20000000; *(uint16_t*)0x20000000 = 1; *(uint8_t*)0x20000002 = 0; *(uint32_t*)0x20000004 = 0x4e23; *(uint32_t*)0x20000548 = 8; *(uint64_t*)0x20000550 = 0x20000340; *(uint64_t*)0x20000340 = 0x20000040; memcpy((void*)0x20000040, "\xd9\xbf\x36\x7b\x50\xf3\xc3\x78\x5c\xf9\x01\x7d\x20\x38\x87\xb8\xcb\xd7\xed\xbf\x0c\x51\x3d\xe7\xca\xce\xd1\x42\x41\x88\x04\x99\xbc\x24\x67\xd8\x99\x71\x0a\x73\x8b\xb0\x00\x36\xea\x71\x48\x3b\x02\x0f\xd8\x5f\xd3\x25\xd5\x6f\x0c\xb0\xbe\xa0\xcb\x3c\xb3\xa1\xc7\x45\x47\xb0\xa6\x53\x22\x92\xff\x38\xc5\x98\xbf\x90\x69\xca\x7e\xd5\xaa\x7c\x50\x0c\x2d\xc7\xb3\x4c\x23\x21\x21\x60\x45\x0a\x28\x2d\x60\xe1\x4a\x89\xe8\xa2\xe6\x34\x5d\x71\x7f\x0c\x24\xce\x9c\xba\xba\x7f\xf5\x83\xc6\x1a\xae\x36\xb0\xbd\x68\xf9\x9a\x77\x6c\xc3\xf1\x58\xe2\x4c\x1d\x43\x0a\x5d\x1a\x1d\x8e\xf8\x45\xb2\x95\x2d\x11\x07\xca\xcd\xa7\x2b\xb8\xc8\x8c\x78\xe6\x0a\xdd\x1d\x7a\xe7", 162); *(uint64_t*)0x20000348 = 0xa2; *(uint64_t*)0x20000350 = 0x20000100; memcpy((void*)0x20000100, "\x37\xb0\xcc\x3f\xd8\xa4\x9c\x87\xcd\x19\xcd\xd3\x01\x8b\xee\x99\x5c\x2a\xc8\xf8\x32\xd6\x56\x98\x5b\x13\x32\x0e\xc9\x76\x69\x85\xd7\xeb\xa8\x60\x5b\xfc\xc4\x34\x68\x06\x37\xf1\x9a\x7a\x58\x7f\x88\x79\xfd\xfc\x85\xa1\x6b\xdd\xcb\x5d\xc0\xd9\x68\x85\xb0\xfe\x36\xb5\xb5\x9d\xb3\xa6\x6b\xd3\x84\x44\x15\xe8\xf8\x5d\xb3\x8f\x03\x44\xf9\xbb\x77\x6c\xd5\x23\x18\x18\x88\xea\x0f\x37\x36\xac\x95\x84\xf3\xf1\x97\xd3\x6b\xea\x82\x14\xfb\xbf\x71\x21\x60\xdb\xe0\xab\x2d\x89\x26\x4d\x65\xdf\xa2\x59\x1b\x90\x1e\x45\xc9\xa3\x27\x8a\xea\x78\x69\x72\x3d\x21\x27\xd1\xf8\x37\x97\xf2\xfd\x93\x65\x73\x8d\x0c\x2c\xae\x61\x3c\xd1\x9e\x60\xf6\xdd\x34\x80\xbd\xb4\x8c\x6a\x49\x29\xc0\xa0\x7d\x2e\x7c\x2d\xcf\xd7\x14\x78\xc8\xc4\x25\x88\xda\xa6\x6a\xd5\x9e\xd9\x76\xe2\xa9\xbd\x04\x74\xd8\xfd\x5d\x5a\xe3\xd2\x70\x35\x8b\xe3\x25\xe6\xfd\xbf\x9b\xad\x17\x56\xc7\x0e\x7a\x51\x65\x8a\x91\x97\x5b\xd6", 219); *(uint64_t*)0x20000358 = 0xdb; *(uint64_t*)0x20000360 = 0x20000200; memcpy((void*)0x20000200, "\xcf\x39\x3b\xe6\x00\x87\x3c\xc7\xfa\xb3\xb2\x63\x8b\x6b\x39\xb4\x8a\xc4\x6d\xf9\x35\x7f\x00\xe6\xb6\x11\x8b\xad\x0f\xdd\xf7\xfe\xe9\xea\xab\xa8\xe6\x5c\xb4\xc9\x79\x72\x27\xd3\xe9\x58\xef\xba\xdb\xcd\x64\x0b\x10\x79\x30\x4a\xc9\x81\x89\x91\xca\x48\x34\xfc\xd9\xde\x21\xda\x0f\x3b\xb9\xa3\xcc\x65\x77\x35\x14\x84\xff\x42\xad\xa9\x75\xcd\x22\xd7\x61\x9d\xd1\x61\x7b\x7c\x9c\xe5\x91\x1b\xd0\x73\x3e\x87\xb9\xb3\x9e\xe0\x5e\x6d\x24\x9e\x98\xd5\x87\x91\xd0\x0e\x7c\xa1\x17", 117); *(uint64_t*)0x20000368 = 0x75; *(uint64_t*)0x20000370 = 0x20000280; memcpy((void*)0x20000280, "\x99\x88\x23\x6f\x6d\x3c\x62\x17\xb8\xdf\x8e\x70\x40\x14\x7c\x2a\x28\x04\xbe\x6c\xcf\x57\xee\xee\x9b\xef\xd0\x76\x06\x66\xca\x41\x6f\xb3\x66\xf9\xd0\xc1\x57\x9c\x0c\x3b\x6b\x31\x50\xdf\x38\xd8\xa5\x6c\x72\xc1\x09\x69\x6d\xfc\x7e\xb2\xdd\xb2\x2f\xf4\xb2\x3e\x22\xaa\xb7\x01\x4b\x08\x30\xe7\x22\x0c\x1f\x4a\x5e\xea\x58\x67\x2f\xe1\x77\x19\x3e\xf7\x8e\x64\x7d\x7c\x6f\x89\x63\x6c\x24\x89\x85\xdf\xb4\xd0\x55\xed\x05\x52\x64\x6b\x8c\x3d\x81\x82\xdb\x23\x8a\x0d\x26\x92\x41\xba\x96\x7c\x10\xc6\x15\xe4\x27\x29\xb4\x14\xb2\xbe\x8f\x7d\xe2\x0b\x65", 135); *(uint64_t*)0x20000378 = 0x87; *(uint64_t*)0x20000558 = 4; *(uint64_t*)0x20000560 = 0x20000480; *(uint64_t*)0x20000480 = 0x20; *(uint32_t*)0x20000488 = 0xffff; *(uint32_t*)0x2000048c = 0; *(uint32_t*)0x20000490 = 0; *(uint32_t*)0x20000494 = -1; *(uint32_t*)0x20000498 = -1; *(uint64_t*)0x200004a0 = 0x20; *(uint32_t*)0x200004a8 = 0xffff; *(uint32_t*)0x200004ac = 1; *(uint32_t*)0x200004b0 = 0xffffff9c; *(uint32_t*)0x200004b4 = 0xffffff9c; *(uint32_t*)0x200004b8 = r[0]; *(uint32_t*)0x200004bc = r[1]; *(uint64_t*)0x200004c0 = 0x30; *(uint32_t*)0x200004c8 = 0xffff; *(uint32_t*)0x200004cc = 1; *(uint32_t*)0x200004d0 = 0xffffff9c; *(uint32_t*)0x200004d4 = 0xffffff9c; *(uint32_t*)0x200004d8 = r[2]; *(uint32_t*)0x200004dc = r[3]; *(uint32_t*)0x200004e0 = 0xffffff9c; *(uint32_t*)0x200004e4 = 0xffffff9c; *(uint32_t*)0x200004e8 = r[4]; *(uint64_t*)0x200004f0 = 0x20; *(uint32_t*)0x200004f8 = 0xffff; *(uint32_t*)0x200004fc = 0; *(uint32_t*)0x20000500 = 0; *(uint32_t*)0x20000504 = 0; *(uint32_t*)0x20000508 = 0; *(uint64_t*)0x20000510 = 0x20; *(uint32_t*)0x20000518 = 0xffff; *(uint32_t*)0x2000051c = 0; *(uint32_t*)0x20000520 = r[5]; *(uint32_t*)0x20000524 = -1; *(uint32_t*)0x20000528 = -1; *(uint64_t*)0x20000568 = 0xb0; *(uint32_t*)0x20000570 = 8; syscall(SYS_sendmsg, -1, 0x20000540ul, 0x400ul); break; case 7: memcpy((void*)0x20000580, "/dev/wsmouse\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000580ul, 0x80ul, 0ul); if (res != -1) r[6] = res; break; case 8: *(uint32_t*)0x200005c0 = 1; syscall(SYS_ioctl, r[6], 0x20004b0aul, 0x200005c0ul); break; case 9: *(uint32_t*)0x20000600 = 0x8001; *(uint32_t*)0x20000604 = 3; *(uint32_t*)0x20000608 = 0x20; *(uint32_t*)0x2000060c = 1; *(uint32_t*)0x20000610 = 0x18; *(uint32_t*)0x20000614 = 3; *(uint32_t*)0x20000618 = 3; *(uint32_t*)0x2000061c = 2; *(uint32_t*)0x20000620 = 8; *(uint32_t*)0x20000624 = 2; *(uint32_t*)0x20000628 = 0x7f; *(uint32_t*)0x2000062c = 3; *(uint32_t*)0x20000630 = 0x7da5; *(uint32_t*)0x20000634 = 1; *(uint32_t*)0x20000638 = 9; *(uint32_t*)0x2000063c = 3; *(uint32_t*)0x20000640 = 0x43b; *(uint32_t*)0x20000644 = 1; *(uint32_t*)0x20000648 = 8; *(uint32_t*)0x2000064c = 1; *(uint32_t*)0x20000650 = 0x401; *(uint32_t*)0x20000654 = 3; *(uint32_t*)0x20000658 = 5; *(uint32_t*)0x2000065c = 1; *(uint32_t*)0x20000660 = 0xdb99; *(uint32_t*)0x20000664 = 2; *(uint32_t*)0x20000668 = 0x57a; *(uint32_t*)0x2000066c = 2; *(uint32_t*)0x20000670 = 0x800; *(uint32_t*)0x20000674 = 1; *(uint32_t*)0x20000678 = 7; *(uint32_t*)0x2000067c = 3; *(uint32_t*)0x20000680 = 3; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 2; *(uint32_t*)0x2000068c = 2; *(uint32_t*)0x20000690 = 2; *(uint32_t*)0x20000694 = 3; *(uint32_t*)0x20000698 = 0x12; *(uint32_t*)0x2000069c = 3; *(uint32_t*)0x200006a0 = 0x20; *(uint32_t*)0x200006a4 = 3; *(uint32_t*)0x200006a8 = 0xffffff66; *(uint32_t*)0x200006ac = 2; *(uint32_t*)0x200006b0 = 0x1000; *(uint32_t*)0x200006b4 = 1; *(uint32_t*)0x200006b8 = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0x34fe; *(uint32_t*)0x200006c4 = 2; *(uint32_t*)0x200006c8 = 6; *(uint32_t*)0x200006cc = 1; *(uint32_t*)0x200006d0 = 0x100; *(uint32_t*)0x200006d4 = 2; *(uint32_t*)0x200006d8 = 1; *(uint32_t*)0x200006dc = 2; *(uint32_t*)0x200006e0 = 2; *(uint32_t*)0x200006e4 = 3; *(uint32_t*)0x200006e8 = 0; *(uint32_t*)0x200006ec = 3; *(uint32_t*)0x200006f0 = 0x120000; *(uint32_t*)0x200006f4 = 3; *(uint32_t*)0x200006f8 = 0x200; *(uint32_t*)0x200006fc = 0xb8acdae4; *(uint32_t*)0x20000700 = 5; syscall(SYS_ioctl, r[6], 0xc1045763ul, 0x20000600ul); break; case 10: memcpy((void*)0x20000040, "\x3e\x42\x0f\x70\x40\x00\x06\xc4\xc1\x29\x72\xe6\x84\xc4\x41\xfc\x11\xb3\x00\x10\x00\x00\x2e\xde\xe9\xcb\xc4\x21\xf8\x50\xd3\xf0\x18\x4a\x00\xc4\x01\x7b\x10\x25\x28\x23\x33\x33\xd0\xfa\xf0\x42\x80\x30\x9b", 51); syz_execute_func(0x20000040); break; case 11: syz_open_pts(); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :320:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] kill_and_wait(pid, &status); ^ :318:3: note: previous statement is here if (current_time_ms() - start < 5000) ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3519088619 -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 (5.95s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/1 (4.51s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/5 (6.49s) csource_test.go:116: --- FAIL: TestGenerate/openbsd/amd64/6 (7.05s) csource_test.go:116: FAIL FAIL github.com/google/syzkaller/pkg/csource 100.332s 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 28.610s ? 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 3.840s ok github.com/google/syzkaller/pkg/ipc 44.955s ? 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.298s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig 4.283s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 40.555s ok github.com/google/syzkaller/pkg/repro 4.952s ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 115.165s 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 19.913s ok github.com/google/syzkaller/prog/test 5.041s ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/darwin/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ok github.com/google/syzkaller/sys/linux 2.222s ? 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 0.199s ? 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 7.077s ok github.com/google/syzkaller/syz-fuzzer 8.476s ok github.com/google/syzkaller/syz-hub 0.912s ok github.com/google/syzkaller/syz-hub/state 4.326s ok github.com/google/syzkaller/syz-manager 26.124s ? github.com/google/syzkaller/syz-runner [no test files] ok github.com/google/syzkaller/syz-verifier 5.625s ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ok github.com/google/syzkaller/tools/syz-kconf (cached) ok github.com/google/syzkaller/tools/syz-linter (cached) ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/parser 0.580s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 4.832s ? 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 13.572s ? 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 4.677s ? 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 4.596s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL