? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/dashboard/app (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ? github.com/google/syzkaller/pkg/html/pages [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [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/executor 3.533s ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 0.677s ok github.com/google/syzkaller/pkg/auth (cached) ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ? github.com/google/syzkaller/pkg/report/crash [no test files] ? github.com/google/syzkaller/pkg/rpctype [no test files] ? github.com/google/syzkaller/pkg/stats/syzbotstats [no test files] ? github.com/google/syzkaller/pkg/testutil [no test files] ? github.com/google/syzkaller/pkg/tools [no test files] ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/darwin/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/akaros [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/syz-runner [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ? github.com/google/syzkaller/tools/syz-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-fillreports [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ? 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] ? 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] ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ? github.com/google/syzkaller/vm/kvm [no test files] ? github.com/google/syzkaller/vm/odroid [no test files] ? 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] ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] ok github.com/google/syzkaller/pkg/bisect 117.071s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 1.853s ok github.com/google/syzkaller/pkg/compiler 7.171s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 0.417s ok github.com/google/syzkaller/pkg/cover 0.061s ok github.com/google/syzkaller/pkg/cover/backend (cached) --- FAIL: TestGenerate (21.64s) --- FAIL: TestGenerate/test/32_fork_shmem (0.00s) testutil.go:33: seed=1712785691833550192 testutil.go:33: seed=1712785691837379776 --- FAIL: TestGenerate/test/32_fork_shmem/3 (0.71s) csource_test.go:150: 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :481:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor2726902030 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/6 (0.74s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:10 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 18; 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, 500); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 15000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :481:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor809543453 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/10 (0.80s) csource_test.go:150: 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); do_sandbox_none(); return 0; } :426:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor4132504992 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/0 (0.91s) csource_test.go:150: 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } syscall(SYS_fallback, 0); memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); syscall(SYS_mutate8, /*a0=*/0x67); res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); syz_errno(/*v=*/4); memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); syz_exit(/*status=*/4); syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); syz_sleep_ms(/*ms=*/8); syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :304:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor949805074 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/12 (0.96s) csource_test.go:150: 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 Repro:true Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :483:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor4189604402 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/8 (0.96s) csource_test.go:150: 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :481:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor3149266617 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/9 (1.05s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:9223372036854775807 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :481:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor3417494403 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/14 (1.13s) csource_test.go:150: 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 Repro:true Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67 + procid*4); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :485:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor1730694014 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/13 (0.64s) csource_test.go:150: 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 Repro:false Trace:true LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { fprintf(stderr, "### start\n"); int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); res = syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; res = syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); res = syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: res = syscall(SYS_fallback, 0); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); res = syscall(SYS_serialize0, /*a=*/0x100000c0); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; res = syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); break; case 6: res = syscall(SYS_mutate8, /*a0=*/0x67); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); if (res != -1) r[0] = res; break; case 8: res = syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: *(uint8_t*)0x10000140 = 0x81; res = syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; res = -1; errno = EFAULT; res = syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); fprintf(stderr, "### call=10 errno=%u\n", res == -1 ? errno : 0); break; case 11: res = -1; errno = EFAULT; res = syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; case 12: res = -1; errno = EFAULT; res = syz_errno(/*v=*/4); fprintf(stderr, "### call=12 errno=%u\n", res == -1 ? errno : 0); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); res = -1; errno = EFAULT; res = syz_execute_func(/*text=*/0x10000080); fprintf(stderr, "### call=13 errno=%u\n", res == -1 ? errno : 0); break; case 14: res = -1; errno = EFAULT; res = syz_exit(/*status=*/4); fprintf(stderr, "### call=14 errno=%u\n", res == -1 ? errno : 0); break; case 15: res = -1; errno = EFAULT; res = syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); fprintf(stderr, "### call=15 errno=%u\n", res == -1 ? errno : 0); break; case 16: res = -1; errno = EFAULT; res = syz_sleep_ms(/*ms=*/8); fprintf(stderr, "### call=16 errno=%u\n", res == -1 ? errno : 0); break; case 17: res = -1; errno = EFAULT; res = syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); fprintf(stderr, "### call=17 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :515:30: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] res = syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor1884127359 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/4 (0.50s) csource_test.go:150: 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 Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: mutate7(&(0x7f0000000000)='\'@\x00', 0x3) (fail_nth: 1) test$align5(&(0x7f0000000040)={{0xc0000, [0x50fa, 0x200, 0x9]}, {0x7, [0x2, 0x8, 0x1]}, 0x8}) (async) mutate7(&(0x7f0000000080)='@\'\x00', 0x3) (rerun: 4) fallback$0() serialize0(&(0x7f00000000c0)={'HI\x00', 'HI\x00'}) test$length16(&(0x7f0000000100)={[0xc2c7, 0x400], 0x2, 0x10, 0x8, 0x4, 0x2}) mutate8(0x3) r0 = unsupported$0(0x0) unsupported$0(r0) test$use_cond_resource(&(0x7f0000000140)={0x81}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@bf21={0x5, {0xb379, 0x1, 0x2, 0x7}}, 0xc) syz_compare_int$2(0x2, 0x5, 0x5ea) syz_errno(0x4) syz_execute_func(&(0x7f0000000080)="a8b137152998429f38389a5a0d6ff780994e8d20f5a6bbeaa5734099c617992a91485b4ef00ebbd00221bda8014679bc39ec") syz_exit(0x4) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x8) syz_test_fuzzer1(0x7fffffffffffffff, 0x6, 0xe) csource_test.go:151: 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 #ifndef SYS_fallback #define SYS_fallback 0 #endif #ifndef SYS_mutate7 #define SYS_mutate7 0 #endif #ifndef SYS_mutate8 #define SYS_mutate8 0 #endif #ifndef SYS_serialize0 #define SYS_serialize0 0 #endif #ifndef SYS_test #define SYS_test 0 #endif #ifndef SYS_unsupported #define SYS_unsupported 0 #endif 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 void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_mmap(volatile long a0, volatile long a1) { return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); } static long syz_errno(volatile long v) { errno = v; return v == 0 ? 0 : -1; } static long syz_exit(volatile long status) { _exit(status); return 0; } static long syz_sleep_ms(volatile long ms) { sleep_ms(ms); return 0; } static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len) { if (want_len != got_len) { errno = EBADF; goto error; } if (memcmp((void*)want, (void*)got, want_len)) { errno = EINVAL; goto error; } return 0; error: return -1; } static long syz_compare_int(volatile long n, ...) { va_list args; va_start(args, n); long v0 = va_arg(args, long); long v1 = va_arg(args, long); long v2 = va_arg(args, long); long v3 = va_arg(args, long); va_end(args); if (n < 2 || n > 4) return errno = E2BIG, -1; if (n <= 2 && v2 != 0) return errno = EFAULT, -1; if (n <= 3 && v3 != 0) return errno = EFAULT, -1; if (v0 != v1) return errno = EINVAL, -1; if (n > 2 && v0 != v2) return errno = EINVAL, -1; if (n > 3 && v0 != v3) return errno = EINVAL, -1; return 0; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } static void fake_crash(const char* name) { exit(1); exit(1); } static long syz_test_fuzzer1(volatile long a, volatile long b, volatile long c) { if (a == 1 && b == 1 && c == 1) fake_crash("first bug"); if (a == 1 && b == 2 && c == 3) fake_crash("second bug"); return 0; } static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 18; 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x10000000, "\'@\000", 3); inject_fault(1); syscall(SYS_mutate7, /*a0=*/0x10000000, /*a1=*/3); break; case 1: *(uint64_t*)0x10000040 = 0xc0000; *(uint16_t*)0x10000048 = 0x50fa; *(uint16_t*)0x1000004a = 0x200; *(uint16_t*)0x1000004c = 9; *(uint64_t*)0x1000004e = 7; *(uint16_t*)0x10000056 = 2; *(uint16_t*)0x10000058 = 8; *(uint16_t*)0x1000005a = 1; *(uint8_t*)0x1000005c = 8; syscall(SYS_test, /*a0=*/0x10000040, 0, 0, 0, 0, 0); break; case 2: memcpy((void*)0x10000080, "@\'\000", 3); syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); { int i; for(i = 0; i < 4; i++) { syscall(SYS_mutate7, /*a0=*/0x10000080, /*a1=*/3); } } break; case 3: syscall(SYS_fallback, 0); break; case 4: memcpy((void*)0x100000c0, "HI\000\000\000\000\000\000\000\000", 10); memcpy((void*)0x100000ca, "HI\000\000\000", 5); syscall(SYS_serialize0, /*a=*/0x100000c0); break; case 5: *(uint64_t*)0x10000100 = 0xc2c7; *(uint64_t*)0x10000108 = 0x400; *(uint8_t*)0x10000110 = 2; *(uint8_t*)0x10000111 = 0x10; *(uint8_t*)0x10000112 = 8; *(uint8_t*)0x10000113 = 4; *(uint8_t*)0x10000114 = 2; syscall(SYS_test, /*a0=*/0x10000100, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_mutate8, /*a0=*/0x67); break; case 7: res = syscall(SYS_unsupported, /*a=*/0); if (res != -1) r[0] = res; break; case 8: syscall(SYS_unsupported, /*a=*/(intptr_t)r[0]); break; case 9: *(uint8_t*)0x10000140 = 0x81; syscall(SYS_test, /*a=*/0x10000140, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x10000000, 0, 1); *(uint8_t*)0x10000040 = 5; *(uint32_t*)0x10000044 = 0xb379; *(uint8_t*)0x10000048 = 1; STORE_BY_BITMASK(uint16_t, , 0x10000048, 2, 8, 8); *(uint16_t*)0x1000004a = 7; syz_compare(/*want=*/0x10000000, /*want_len=*/1, /*got=*/0x10000040, /*got_len=*/0xc); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/5, /*v1=*/0x5ea, 0, 0); break; case 12: syz_errno(/*v=*/4); break; case 13: memcpy((void*)0x10000080, "\xa8\xb1\x37\x15\x29\x98\x42\x9f\x38\x38\x9a\x5a\x0d\x6f\xf7\x80\x99\x4e\x8d\x20\xf5\xa6\xbb\xea\xa5\x73\x40\x99\xc6\x17\x99\x2a\x91\x48\x5b\x4e\xf0\x0e\xbb\xd0\x02\x21\xbd\xa8\x01\x46\x79\xbc\x39\xec", 50); syz_execute_func(/*text=*/0x10000080); break; case 14: syz_exit(/*status=*/4); break; case 15: syz_mmap(/*addr=*/0x10ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/8); break; case 17: syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); break; } } int main(void) { syz_mmap(/*addr=*/0x10000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :481:24: error: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Werror,-Wconstant-conversion] syz_test_fuzzer1(/*a=*/0x7fffffffffffffff, /*b=*/6, /*c=*/0xe); ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~ 1 error generated. compiler invocation: clang [-o /tmp/syz-executor4219544263 -DGOOS_test=1 -DGOARCH_32_fork_shmem=1 -DHOSTGOOS_freebsd=1 -x c - -m32 --target=i386-unknown-freebsd14.0 -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 -lc++ -static -Wno-overflow] --- FAIL: TestGenerate/test/32_fork_shmem/1 (0.65s) csource_test.go:148: --- FAIL: TestGenerate/test/32_fork_shmem/2 (0.51s) csource_test.go:148: --- FAIL: TestGenerate/test/32_fork_shmem/7 (1.56s) csource_test.go:148: --- FAIL: TestGenerate/test/32_fork_shmem/5 (0.88s) csource_test.go:148: FAIL FAIL github.com/google/syzkaller/pkg/csource 26.288s ok github.com/google/syzkaller/pkg/db (cached) ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore (cached) ok github.com/google/syzkaller/pkg/fuzzer 32.604s ok github.com/google/syzkaller/pkg/gce (cached) ok github.com/google/syzkaller/pkg/host (cached) ok github.com/google/syzkaller/pkg/html (cached) ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/image (cached) ok github.com/google/syzkaller/pkg/instance 5.131s ok github.com/google/syzkaller/pkg/ipc 16.268s 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/mgrconfig 3.300s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 9.982s ok github.com/google/syzkaller/pkg/repro 3.184s ok github.com/google/syzkaller/pkg/runtest 85.613s ok github.com/google/syzkaller/pkg/serializer (cached) ok github.com/google/syzkaller/pkg/signal (cached) ok github.com/google/syzkaller/pkg/stats 1.202s 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) ok github.com/google/syzkaller/pkg/tool (cached) ok github.com/google/syzkaller/pkg/vcs (cached) ok github.com/google/syzkaller/prog (cached) ok github.com/google/syzkaller/prog/test (cached) ok github.com/google/syzkaller/sys/linux (cached) ok github.com/google/syzkaller/sys/netbsd (cached) ok github.com/google/syzkaller/sys/openbsd (cached) ok github.com/google/syzkaller/syz-ci 11.063s ok github.com/google/syzkaller/syz-fuzzer 0.086s ok github.com/google/syzkaller/syz-hub 0.069s ok github.com/google/syzkaller/syz-hub/state 0.194s ok github.com/google/syzkaller/syz-manager 3.737s ok github.com/google/syzkaller/syz-verifier 2.463s ok github.com/google/syzkaller/tools/syz-kconf (cached) ok github.com/google/syzkaller/tools/syz-linter (cached) ok github.com/google/syzkaller/tools/syz-testbed 2.093s ok github.com/google/syzkaller/tools/syz-trace2syz/parser (cached) ok github.com/google/syzkaller/tools/syz-trace2syz/proggen (cached) ok github.com/google/syzkaller/vm 9.864s ok github.com/google/syzkaller/vm/isolated 1.813s ok github.com/google/syzkaller/vm/proxyapp 79.906s ok github.com/google/syzkaller/vm/vmimpl 1.548s FAIL