? github.com/google/syzkaller/dashboard/api [no test files] ok github.com/google/syzkaller/dashboard/app 8.343s ok github.com/google/syzkaller/dashboard/dashapi (cached) ok github.com/google/syzkaller/executor 3.265s ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 2.511s ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect 174.802s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 9.339s ? github.com/google/syzkaller/pkg/clangtool [no test files] ok github.com/google/syzkaller/pkg/compiler 16.493s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 10.298s ok github.com/google/syzkaller/pkg/cover 8.706s ok github.com/google/syzkaller/pkg/cover/backend 8.248s ok github.com/google/syzkaller/pkg/coveragedb (cached) ? github.com/google/syzkaller/pkg/coveragedb/mocks [no test files] ? github.com/google/syzkaller/pkg/coveragedb/spannerclient [no test files] ok github.com/google/syzkaller/pkg/covermerger (cached) ? github.com/google/syzkaller/pkg/covermerger/mocks [no test files] --- FAIL: TestGenerate (14.14s) --- FAIL: TestGenerate/openbsd/amd64 (0.01s) testutil.go:35: seed=1744706749781317287 testutil.go:35: seed=1744706749793846372 --- FAIL: TestGenerate/openbsd/amd64/0 (1.50s) csource_test.go:149: opts: {Threaded:false Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } #define CAST 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 && errno != EPERM) 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 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {} inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ syz_open_pts(); } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :310:2: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3210178395 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/14 (1.46s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:true LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } 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)) { } fprintf(stderr, "### start\n"); int i, call, thread; for (call = 0; call < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); fprintf(stderr, "### call=0 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); fprintf(stderr, "### call=1 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 2: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); fprintf(stderr, "### call=2 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); fprintf(stderr, "### call=3 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); fprintf(stderr, "### call=4 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); fprintf(stderr, "### call=5 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); fprintf(stderr, "### call=6 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); fprintf(stderr, "### call=7 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 8: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); fprintf(stderr, "### call=8 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); res = -1; errno = EFAULT; NONFAILING(res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ fprintf(stderr, "### call=9 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 10: res = -1; errno = EFAULT; res = syz_open_pts(); fprintf(stderr, "### call=10 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :497:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4229369794 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/9 (1.80s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:-9223372036854775808 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } 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 < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :470:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1311876403 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/12 (1.67s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:false HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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 const char* setup_fault() { return NULL; } 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 CAST 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; } 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 < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); do_sandbox_none(); return 0; } :417:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2140895841 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/2 (2.83s) csource_test.go:149: opts: {Threaded:true Repeat:false RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static 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 int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void loop(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 11; 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 (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :390:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1808984289 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/8 (2.75s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:setuid SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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); } 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 < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_setuid(); return 0; } :493:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3566174746 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/3 (3.00s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:10 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } 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 < 11; 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 (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (; iter < 10; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :470:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1704927889 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/7 (3.11s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox: SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } 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 < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); loop(); return 0; } :445:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2281197390 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/15 (2.93s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:2 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } 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 < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :472:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2236496746 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/4 (2.99s) csource_test.go:149: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: r0 = fcntl$dupfd(0xffffffffffffff9c, 0xa, 0xffffffffffffffff) (fail_nth: 1) ioctl$TIOCSETAW(r0, 0x802c7415, &(0x7f0000000000)={0x3, 0x0, 0x80000000, 0xffffffff, "00f8399c3d6112124f19f62f3079f10966c6340c", 0x9, 0x9}) (async) getsockopt$SO_PEERCRED(r0, 0xffff, 0x1022, &(0x7f0000000040)={0x0}, 0xc) (rerun: 4) fcntl$setown(r0, 0x6, r1) r2 = openat$tty(0xffffffffffffff9c, &(0x7f0000000080), 0x40, 0x0) ioctl$TIOCMSET(r2, 0x8004746d, &(0x7f00000000c0)=0x21d1) ioctl$TIOCSETD(r2, 0x8004741b, &(0x7f0000000100)=0x7ff) ioctl$VMM_IOC_RESETCPU(r0, 0x82405605, &(0x7f0000000140)={0x80000001, 0x3, {[0x4, 0x4, 0x7, 0x100000001, 0x200, 0x400, 0x9100, 0x5, 0x8, 0x6, 0xfffffffffffffffc, 0x100000000, 0x101, 0x1, 0x3, 0x1, 0xffffffff, 0xe4e1], [0xbf, 0x7, 0x0, 0xfffffffffffffff9, 0x6, 0xffff, 0x69, 0x2, 0x5], [0x7, 0x9, 0x14000, 0x0, 0x1, 0x2, 0x7], [0x5, 0x4, 0x5, 0xb400, 0x1000, 0x5], [{0x4, 0x8, 0x3, 0x9}, {0x0, 0x3, 0x7, 0x28ad}, {0x8, 0x4, 0x2, 0x1}, {0xfe01, 0x100, 0x3, 0x3}, {0x0, 0x3ff, 0x25bce9cf, 0x9}, {0x45, 0x2, 0x3, 0x3}, {0x4, 0x5, 0x2, 0x373}, {0x6, 0xb83a, 0x3, 0xfffffffffffffff3}], {0x2, 0xaf1, 0x24, 0x401}, {0x200, 0x7, 0x4, 0x716}}}) ioctl$TIOCSPGRP(r2, 0x40047477, &(0x7f0000000380)) mknodat(r0, &(0x7f00000003c0)='./file0\x00', 0x100, 0xfa5) syz_emit_ethernet(0xbb, &(0x7f0000000000)={@empty, @random="4684324022c4", [{[], {0x8100, 0x0, 0x1, 0x3}}], {@ipv4={0x800, {{0x9, 0x4, 0x0, 0x3b, 0xa9, 0x66, 0x6, 0xb, 0x29, 0x0, @multicast2, @broadcast, {[@ra={0x94, 0x6, 0x3}, @generic={0x7, 0x9, "c115ea1eaefbc8"}]}}, @generic="482989004eef13272d3600d5eb49223812454e7d1509294761d174d2001b4480c1da963ed768316d2dcf1c97fd111df13673abbd64af96446b720f18099c3601d089e1d0c608151e98bd7208cfdac38fe42b64311184d5cb5f655005509e5d02a9310955cbcadd2e096ff8bf6a1f70260fe1f6152e6a092ad4c22fbd2e8d65fe01c49197dc"}}}}) syz_extract_tcp_res(&(0x7f00000000c0), 0x5, 0x1) syz_open_pts() csource_test.go:150: 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 #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); while (rmdir(dir)) { exit(1); } } static int inject_fault(int nth) { return 0; } static const char* setup_fault() { return NULL; } 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 CAST 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; } 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 < 11; 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 (call == 1) break; 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/0xffffff9c, /*cmd=F_DUPFD_CLOEXEC*/0xa, /*arg=*/-1); if (res != -1) r[0] = res; break; case 1: *(uint32_t*)0x200000000000 = 3; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000008 = 0x80000000; *(uint32_t*)0x20000000000c = -1; memcpy((void*)0x200000000010, "\x00\xf8\x39\x9c\x3d\x61\x12\x12\x4f\x19\xf6\x2f\x30\x79\xf1\x09\x66\xc6\x34\x0c", 20); *(uint32_t*)0x200000000024 = 9; *(uint32_t*)0x200000000028 = 9; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x802c7415, /*arg=*/0x200000000000); break; case 2: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); for (int i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(getsockopt))(/*fd=*/r[0], /*level=*/0xffff, /*optname=*/0x1022, /*optval=*/0x200000000040, /*optlen=*/0xc); } if (res != -1) r[1] = *(uint32_t*)0x200000000040; break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(fcntl))(/*fd=*/r[0], /*cmd=*/6, /*pid=*/r[1]); break; case 4: memcpy((void*)0x200000000080, "/dev/tty\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x200000000080, /*flags=O_ASYNC*/0x40, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: *(uint32_t*)0x2000000000c0 = 0x21d1; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004746d, /*arg=*/0x2000000000c0); break; case 6: *(uint32_t*)0x200000000100 = 0x7ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x8004741b, /*arg=*/0x200000000100); break; case 7: *(uint32_t*)0x200000000140 = 0x80000001; *(uint32_t*)0x200000000144 = 3; *(uint64_t*)0x200000000148 = 4; *(uint64_t*)0x200000000150 = 4; *(uint64_t*)0x200000000158 = 7; *(uint64_t*)0x200000000160 = 0x100000001; *(uint64_t*)0x200000000168 = 0x200; *(uint64_t*)0x200000000170 = 0x400; *(uint64_t*)0x200000000178 = 0x9100; *(uint64_t*)0x200000000180 = 5; *(uint64_t*)0x200000000188 = 8; *(uint64_t*)0x200000000190 = 6; *(uint64_t*)0x200000000198 = 0xfffffffffffffffc; *(uint64_t*)0x2000000001a0 = 0x100000000; *(uint64_t*)0x2000000001a8 = 0x101; *(uint64_t*)0x2000000001b0 = 1; *(uint64_t*)0x2000000001b8 = 3; *(uint64_t*)0x2000000001c0 = 1; *(uint64_t*)0x2000000001c8 = 0xffffffff; *(uint64_t*)0x2000000001d0 = 0xe4e1; *(uint64_t*)0x2000000001d8 = 0xbf; *(uint64_t*)0x2000000001e0 = 7; *(uint64_t*)0x2000000001e8 = 0; *(uint64_t*)0x2000000001f0 = 0xfffffffffffffff9; *(uint64_t*)0x2000000001f8 = 6; *(uint64_t*)0x200000000200 = 0xffff; *(uint64_t*)0x200000000208 = 0x69; *(uint64_t*)0x200000000210 = 2; *(uint64_t*)0x200000000218 = 5; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 7; *(uint64_t*)0x200000000230 = 9; *(uint64_t*)0x200000000238 = 0x14000; *(uint64_t*)0x200000000240 = 0; *(uint64_t*)0x200000000248 = 1; *(uint64_t*)0x200000000250 = 2; *(uint64_t*)0x200000000258 = 7; *(uint64_t*)0x200000000260 = 5; *(uint64_t*)0x200000000268 = 4; *(uint64_t*)0x200000000270 = 5; *(uint64_t*)0x200000000278 = 0xb400; *(uint64_t*)0x200000000280 = 0x1000; *(uint64_t*)0x200000000288 = 5; *(uint16_t*)0x200000000290 = 4; *(uint32_t*)0x200000000294 = 8; *(uint32_t*)0x200000000298 = 3; *(uint64_t*)0x2000000002a0 = 9; *(uint16_t*)0x2000000002a8 = 0; *(uint32_t*)0x2000000002ac = 3; *(uint32_t*)0x2000000002b0 = 7; *(uint64_t*)0x2000000002b8 = 0x28ad; *(uint16_t*)0x2000000002c0 = 8; *(uint32_t*)0x2000000002c4 = 4; *(uint32_t*)0x2000000002c8 = 2; *(uint64_t*)0x2000000002d0 = 1; *(uint16_t*)0x2000000002d8 = 0xfe01; *(uint32_t*)0x2000000002dc = 0x100; *(uint32_t*)0x2000000002e0 = 3; *(uint64_t*)0x2000000002e8 = 3; *(uint16_t*)0x2000000002f0 = 0; *(uint32_t*)0x2000000002f4 = 0x3ff; *(uint32_t*)0x2000000002f8 = 0x25bce9cf; *(uint64_t*)0x200000000300 = 9; *(uint16_t*)0x200000000308 = 0x45; *(uint32_t*)0x20000000030c = 2; *(uint32_t*)0x200000000310 = 3; *(uint64_t*)0x200000000318 = 3; *(uint16_t*)0x200000000320 = 4; *(uint32_t*)0x200000000324 = 5; *(uint32_t*)0x200000000328 = 2; *(uint64_t*)0x200000000330 = 0x373; *(uint16_t*)0x200000000338 = 6; *(uint32_t*)0x20000000033c = 0xb83a; *(uint32_t*)0x200000000340 = 3; *(uint64_t*)0x200000000348 = 0xfffffffffffffff3; *(uint16_t*)0x200000000350 = 2; *(uint32_t*)0x200000000354 = 0xaf1; *(uint32_t*)0x200000000358 = 0x24; *(uint64_t*)0x200000000360 = 0x401; *(uint16_t*)0x200000000368 = 0x200; *(uint32_t*)0x20000000036c = 7; *(uint32_t*)0x200000000370 = 4; *(uint64_t*)0x200000000378 = 0x716; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0x82405605, /*arg=*/0x200000000140); break; case 8: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0x40047477, /*arg=*/0x200000000380); break; case 9: memcpy((void*)0x2000000003c0, "./file0\000", 8); NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ break; case 10: syz_open_pts(); break; } } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason); use_temporary_dir(); do_sandbox_none(); return 0; } :470:3: error: call to undeclared function 'NONFAILING'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] NONFAILING(((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(mknodat))(/*dirfd=*/r[0], /*file=*/0x2000000003c0, /*mode=*/0x100, /*dev=*/0xfa5)); /* major = 15, minor = 165 */ ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1380512938 -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 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument] --- FAIL: TestGenerate/openbsd/amd64/1 (3.33s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/11 (2.02s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/10 (1.90s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/5 (3.79s) csource_test.go:147: --- FAIL: TestGenerate/openbsd/amd64/6 (1.59s) csource_test.go:147: FAIL FAIL github.com/google/syzkaller/pkg/csource 30.516s ok github.com/google/syzkaller/pkg/db (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/declextract [no test files] ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore (cached) ok github.com/google/syzkaller/pkg/flatrpc (cached) ok github.com/google/syzkaller/pkg/fuzzer 9.318s ok github.com/google/syzkaller/pkg/fuzzer/queue (cached) ok github.com/google/syzkaller/pkg/gce (cached) ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/gcs/mocks [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ? github.com/google/syzkaller/pkg/html [no test files] ok github.com/google/syzkaller/pkg/html/pages (cached) ok github.com/google/syzkaller/pkg/html/urlutil (cached) ? github.com/google/syzkaller/pkg/ifaceprobe [no test files] ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/ifuzz/arm64 (cached) ? github.com/google/syzkaller/pkg/ifuzz/arm64/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/arm64/generated [no test files] ? 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/image 13.131s ok github.com/google/syzkaller/pkg/instance 11.296s ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/pkg/kconfig (cached) ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/manager 11.815s ok github.com/google/syzkaller/pkg/mgrconfig 11.298s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 24.170s ? github.com/google/syzkaller/pkg/report/crash [no test files] ok github.com/google/syzkaller/pkg/repro 12.487s ok github.com/google/syzkaller/pkg/rpcserver 12.664s ? github.com/google/syzkaller/pkg/rpcserver/mocks [no test files] ? github.com/google/syzkaller/pkg/rpctype [no test files] ok github.com/google/syzkaller/pkg/runtest 41.703s ok github.com/google/syzkaller/pkg/serializer (cached) ok github.com/google/syzkaller/pkg/signal (cached) ok github.com/google/syzkaller/pkg/stat (cached) ok github.com/google/syzkaller/pkg/stat/sample (cached) ? github.com/google/syzkaller/pkg/stat/syzbotstats [no test files] ok github.com/google/syzkaller/pkg/subsystem (cached) ok github.com/google/syzkaller/pkg/subsystem/linux (cached) ok github.com/google/syzkaller/pkg/subsystem/lists (cached) ok github.com/google/syzkaller/pkg/symbolizer (cached) ? github.com/google/syzkaller/pkg/testutil [no test files] ok github.com/google/syzkaller/pkg/tool (cached) ? github.com/google/syzkaller/pkg/tools [no test files] ok github.com/google/syzkaller/pkg/validator (cached) ok github.com/google/syzkaller/pkg/vcs (cached) ok github.com/google/syzkaller/pkg/vminfo 21.586s ok github.com/google/syzkaller/prog 105.221s ok github.com/google/syzkaller/prog/test 10.698s ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/freebsd [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/layout [no test files] ? github.com/google/syzkaller/sys/generated [no test files] ok github.com/google/syzkaller/sys/linux 11.151s ok github.com/google/syzkaller/sys/netbsd 9.844s ok github.com/google/syzkaller/sys/openbsd 10.885s ? 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/trusty [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ok github.com/google/syzkaller/syz-ci 66.335s ok github.com/google/syzkaller/syz-cluster/controller (cached) ? github.com/google/syzkaller/syz-cluster/dashboard [no test files] ? github.com/google/syzkaller/syz-cluster/db-mgmt [no test files] ? github.com/google/syzkaller/syz-cluster/pkg/api [no test files] ? github.com/google/syzkaller/syz-cluster/pkg/app [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/blob (cached) ok github.com/google/syzkaller/syz-cluster/pkg/controller (cached) ok github.com/google/syzkaller/syz-cluster/pkg/db (cached) ok github.com/google/syzkaller/syz-cluster/pkg/report (cached) ? github.com/google/syzkaller/syz-cluster/pkg/service [no test files] ok github.com/google/syzkaller/syz-cluster/pkg/triage (cached) ? github.com/google/syzkaller/syz-cluster/pkg/workflow [no test files] ok github.com/google/syzkaller/syz-cluster/reporter (cached) ok github.com/google/syzkaller/syz-cluster/series-tracker (cached) ? github.com/google/syzkaller/syz-cluster/workflow/boot-step [no test files] ? github.com/google/syzkaller/syz-cluster/workflow/build-step [no test files] ok github.com/google/syzkaller/syz-cluster/workflow/fuzz-step 16.422s ? github.com/google/syzkaller/syz-cluster/workflow/triage-step [no test files] ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager 13.638s ? github.com/google/syzkaller/tools/arm64 [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-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-covermerger [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ok github.com/google/syzkaller/tools/syz-db 14.121s ? github.com/google/syzkaller/tools/syz-db-export [no test files] ok github.com/google/syzkaller/tools/syz-declextract 11.928s ? github.com/google/syzkaller/tools/syz-diff [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-fillreports [no test files] ? github.com/google/syzkaller/tools/syz-fix-analyzer [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-gemini-seed [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-lore [no test files] ? 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-query-subsystems [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-showprio [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ok github.com/google/syzkaller/tools/syz-testbed 13.640s ? 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 11.404s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 13.499s ? 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 22.555s ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? github.com/google/syzkaller/vm/cuttlefish [no test files] ok github.com/google/syzkaller/vm/dispatcher (cached) ? 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 7.515s ok github.com/google/syzkaller/vm/proxyapp 12.356s ? github.com/google/syzkaller/vm/proxyapp/mocks [no test files] ? github.com/google/syzkaller/vm/proxyapp/proxyrpc [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ? github.com/google/syzkaller/vm/starnix [no test files] ok github.com/google/syzkaller/vm/vmimpl 6.414s ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] FAIL