? 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/gcs [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/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ? 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/gen [no test files] ? github.com/google/syzkaller/sys/akaros [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/darwin [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? 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/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ? github.com/google/syzkaller/syz-runner [no test files] ok github.com/google/syzkaller/executor 13.487s ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 1.459s ok github.com/google/syzkaller/pkg/auth (cached) ok github.com/google/syzkaller/pkg/bisect (cached) ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build (cached) ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-crush [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-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-fillreports [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-fmt [no test files] ok github.com/google/syzkaller/pkg/compiler 14.337s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus (cached) ok github.com/google/syzkaller/pkg/cover (cached) ok github.com/google/syzkaller/pkg/cover/backend (cached) ? github.com/google/syzkaller/tools/syz-lore [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [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] --- FAIL: TestGenerate (15.32s) --- FAIL: TestGenerate/test/64 (0.00s) testutil.go:33: seed=1712223826541331155 testutil.go:33: seed=1712223826545689571 --- FAIL: TestGenerate/test/64/5 (1.04s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:4 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :307:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor702349424 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/7 (1.06s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox: SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); loop(); return 0; } :298:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1235259386 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/0 (1.07s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } 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); static void loop(void) { execute_one(); } void execute_one(void) { *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); syscall(SYS_test, 0, 0, 0, 0, 0, 0); memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); syz_errno(/*v=*/0xfffffff9); memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); syz_exit(/*status=*/0x8001); syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); syz_sleep_ms(/*ms=*/0x81); syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :153:2: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3940775522 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/8 (1.18s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :305:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2720287445 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/9 (1.23s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :305:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1418354372 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/6 (1.23s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :305:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1586728931 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/10 (1.25s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); do_sandbox_none(); return 0; } :292:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3624181053 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/13 (1.13s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); res = syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); fprintf(stderr, "### call=0 errno=%u\n", res == -1 ? errno : 0); break; case 1: res = syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); fprintf(stderr, "### call=1 errno=%u\n", res == -1 ? errno : 0); break; case 2: *(uint64_t*)0x20000040 = 0; res = syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); fprintf(stderr, "### call=2 errno=%u\n", res == -1 ? errno : 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); res = syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); fprintf(stderr, "### call=3 errno=%u\n", res == -1 ? errno : 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; res = syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); fprintf(stderr, "### call=4 errno=%u\n", res == -1 ? errno : 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; res = syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); fprintf(stderr, "### call=5 errno=%u\n", res == -1 ? errno : 0); break; case 6: res = syscall(SYS_test, 0, 0, 0, 0, 0, 0); fprintf(stderr, "### call=6 errno=%u\n", res == -1 ? errno : 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); res = syscall(SYS_serialize2, /*a=*/0x20000140ul); fprintf(stderr, "### call=7 errno=%u\n", res == -1 ? errno : 0); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; res = syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); fprintf(stderr, "### call=8 errno=%u\n", res == -1 ? errno : 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; res = syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); fprintf(stderr, "### call=9 errno=%u\n", res == -1 ? errno : 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; res = -1; errno = EFAULT; res = syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); 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=*/8, /*v1=*/0xdf3481080, 0, 0); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; case 12: res = -1; errno = EFAULT; res = syz_errno(/*v=*/0xfffffff9); fprintf(stderr, "### call=12 errno=%u\n", res == -1 ? errno : 0); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); res = -1; errno = EFAULT; res = syz_execute_func(/*text=*/0x20000080); fprintf(stderr, "### call=13 errno=%u\n", res == -1 ? errno : 0); break; case 14: res = -1; errno = EFAULT; res = syz_exit(/*status=*/0x8001); fprintf(stderr, "### call=14 errno=%u\n", res == -1 ? errno : 0); break; case 15: res = -1; errno = EFAULT; res = syz_mmap(/*addr=*/0x20ffc000, /*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=*/0x81); fprintf(stderr, "### call=16 errno=%u\n", res == -1 ? errno : 0); break; case 17: res = -1; errno = EFAULT; res = syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); fprintf(stderr, "### call=17 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :307:9: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] res = syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3870344200 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/3 (1.13s) 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: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :305:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor926367524 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/1 (1.07s) 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:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: test$auto2(0x42, &(0x7f0000000000)={0x10, {0xc}}, 0x10, 0x3) (fail_nth: 1) test$opt1(0x0) (async) test$opt1(&(0x7f0000000040)) (rerun: 4) test$text_x86_16(&(0x7f0000000080)="0fc77993660f3881bf0000b8fa000f00d0660f3880bd0500b8fe000f00d80f011ef20466b9e00100000f32f2ad0f06260f009ac766", 0x35) test$auto2(0x42, &(0x7f00000000c0)={0x10, {0xc}}, 0x10, 0x5) test$auto2(0x42, &(0x7f0000000100)={0x10, {0xc}}, 0x10, 0x7fff) test$res0() serialize2(&(0x7f0000000140)="d0a6001a614a497b0489da2b81f706f2b3e2efa6d1e8400f094768395bcaec2cb3432c7bc1a0751e8d12ce539ed0b4b106b87e445db9072e9768da519011bad1df9ef85321bcf7cc3b940f1dd5d5b4537085ee2cd98ffe2ea9e7c593f353bf927432cbea53574249a461abd32120a0c2453be8c55948429521ea9c83fffcc71bb9611efd28038ca612faf76536e95675cb10b07c36e9474cee03d1f9cfb5c046e76ee420db742abd77ec5529ad749515") test$opt1(&(0x7f0000000200)=0x8000000000000001) test$length30(&(0x7f0000000300)={{{0x9, 0x18, 0x1, 0x3, 0x5, 0x6}, {'C', "a4a013", "ee5840f264", "abd9965f8850"}, &(0x7f0000000240)={'+', "6ca8bb", "9e12420ff1", "3482601bdcaf"}, &(0x7f00000002c0)=&(0x7f0000000280)={"c5", "d34dfa", "5c1cc6b45c", "3cd2f74a6041"}, 0x2}, 0x4}, 0x40, &(0x7f0000000380)=0x18, 0x2) syz_compare(&(0x7f0000000000)='}}\xed-\x00', 0x5, &(0x7f0000000040)=@overlay2={0x82ba5ad, 0x3}, 0x10) syz_compare_int$2(0x2, 0x8, 0xdf3481080) syz_errno(0xfffffff9) syz_execute_func(&(0x7f0000000080)="d0a8031ab89eb912b3b32ce00141f41f74f7dbd56d50605fb625f9528384cc755ccb13afde7b11a1ab12de8cd9a163a88f22") syz_exit(0x8001) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x81) syz_test_fuzzer1(0x4, 0x7, 0x0) 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 #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static 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; } 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); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000000 = 0x10; *(uint32_t*)0x20000004 = 0xc; *(uint32_t*)0x20000008 = 0x43; *(uint32_t*)0x2000000c = 0; inject_fault(1); syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); break; case 1: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 2: *(uint64_t*)0x20000040 = 0; syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000040ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000080, "\x0f\xc7\x79\x93\x66\x0f\x38\x81\xbf\x00\x00\xb8\xfa\x00\x0f\x00\xd0\x66\x0f\x38\x80\xbd\x05\x00\xb8\xfe\x00\x0f\x00\xd8\x0f\x01\x1e\xf2\x04\x66\xb9\xe0\x01\x00\x00\x0f\x32\xf2\xad\x0f\x06\x26\x0f\x00\x9a\xc7\x66", 53); syscall(SYS_test, /*a0=*/0x20000080ul, /*a1=*/0x35, 0, 0, 0, 0); break; case 4: *(uint32_t*)0x200000c0 = 0x10; *(uint32_t*)0x200000c4 = 0xc; *(uint32_t*)0x200000c8 = 0x43; *(uint32_t*)0x200000cc = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x200000c0ul, /*c=*/0x10, /*d=*/5, 0, 0); break; case 5: *(uint32_t*)0x20000100 = 0x10; *(uint32_t*)0x20000104 = 0xc; *(uint32_t*)0x20000108 = 0x43; *(uint32_t*)0x2000010c = 0; syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000100ul, /*c=*/0x10, /*d=*/0x7fff, 0, 0); break; case 6: syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 7: memcpy((void*)0x20000140, "\xd0\xa6\x00\x1a\x61\x4a\x49\x7b\x04\x89\xda\x2b\x81\xf7\x06\xf2\xb3\xe2\xef\xa6\xd1\xe8\x40\x0f\x09\x47\x68\x39\x5b\xca\xec\x2c\xb3\x43\x2c\x7b\xc1\xa0\x75\x1e\x8d\x12\xce\x53\x9e\xd0\xb4\xb1\x06\xb8\x7e\x44\x5d\xb9\x07\x2e\x97\x68\xda\x51\x90\x11\xba\xd1\xdf\x9e\xf8\x53\x21\xbc\xf7\xcc\x3b\x94\x0f\x1d\xd5\xd5\xb4\x53\x70\x85\xee\x2c\xd9\x8f\xfe\x2e\xa9\xe7\xc5\x93\xf3\x53\xbf\x92\x74\x32\xcb\xea\x53\x57\x42\x49\xa4\x61\xab\xd3\x21\x20\xa0\xc2\x45\x3b\xe8\xc5\x59\x48\x42\x95\x21\xea\x9c\x83\xff\xfc\xc7\x1b\xb9\x61\x1e\xfd\x28\x03\x8c\xa6\x12\xfa\xf7\x65\x36\xe9\x56\x75\xcb\x10\xb0\x7c\x36\xe9\x47\x4c\xee\x03\xd1\xf9\xcf\xb5\xc0\x46\xe7\x6e\xe4\x20\xdb\x74\x2a\xbd\x77\xec\x55\x29\xad\x74\x95\x15", 176); syscall(SYS_serialize2, /*a=*/0x20000140ul); break; case 8: *(uint64_t*)0x20000200 = 0x8000000000000001; syscall(SYS_test, /*a0=*/0x20000200ul, 0, 0, 0, 0, 0); break; case 9: *(uint16_t*)0x20000300 = 9; *(uint32_t*)0x20000304 = 0x18; *(uint32_t*)0x20000308 = 1; *(uint32_t*)0x2000030c = 3; *(uint32_t*)0x20000310 = 5; *(uint32_t*)0x20000314 = 6; memset((void*)0x20000318, 67, 1); memcpy((void*)0x20000319, "\xa4\xa0\x13", 3); memcpy((void*)0x2000031c, "\xee\x58\x40\xf2\x64", 5); memcpy((void*)0x20000321, "\xab\xd9\x96\x5f\x88\x50", 6); *(uint64_t*)0x20000328 = 0x20000240; memset((void*)0x20000240, 43, 1); memcpy((void*)0x20000241, "\x6c\xa8\xbb", 3); memcpy((void*)0x20000244, "\x9e\x12\x42\x0f\xf1", 5); memcpy((void*)0x20000249, "\x34\x82\x60\x1b\xdc\xaf", 6); *(uint64_t*)0x20000330 = 0x200002c0; *(uint64_t*)0x200002c0 = 0x20000280; memset((void*)0x20000280, 197, 1); memcpy((void*)0x20000281, "\xd3\x4d\xfa", 3); memcpy((void*)0x20000284, "\x5c\x1c\xc6\xb4\x5c", 5); memcpy((void*)0x20000289, "\x3c\xd2\xf7\x4a\x60\x41", 6); *(uint32_t*)0x20000338 = 2; *(uint32_t*)0x20000340 = 4; *(uint32_t*)0x20000380 = 0x18; syscall(SYS_test, /*a0=*/0x20000300ul, /*a1=*/0x40, /*a2=*/0x20000380ul, /*a3=*/2, 0, 0); break; case 10: memcpy((void*)0x20000000, "}}\355-\000", 5); *(uint32_t*)0x20000040 = 0x82ba5ad; *(uint32_t*)0x20000044 = 3; syz_compare(/*want=*/0x20000000, /*want_len=*/5, /*got=*/0x20000040, /*got_len=*/0x10); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/8, /*v1=*/0xdf3481080, 0, 0); break; case 12: syz_errno(/*v=*/0xfffffff9); break; case 13: memcpy((void*)0x20000080, "\xd0\xa8\x03\x1a\xb8\x9e\xb9\x12\xb3\xb3\x2c\xe0\x01\x41\xf4\x1f\x74\xf7\xdb\xd5\x6d\x50\x60\x5f\xb6\x25\xf9\x52\x83\x84\xcc\x75\x5c\xcb\x13\xaf\xde\x7b\x11\xa1\xab\x12\xde\x8c\xd9\xa1\x63\xa8\x8f\x22", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x8001); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x81); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/7, /*c=*/0); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :305:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, /*a=*/0x42ul, /*b=*/0x20000000ul, /*c=*/0x10, /*d=*/3, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1209641420 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/14 (1.00s) csource_test.go:148: --- FAIL: TestGenerate/test/64/4 (1.28s) csource_test.go:148: --- FAIL: TestGenerate/test/64/2 (1.14s) csource_test.go:148: --- FAIL: TestGenerate/test/64/12 (1.20s) csource_test.go:148: FAIL FAIL github.com/google/syzkaller/pkg/csource 25.362s 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 (cached) 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 (cached) ok github.com/google/syzkaller/pkg/ipc (cached) 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 (cached) ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report (cached) ok github.com/google/syzkaller/pkg/repro (cached) ok github.com/google/syzkaller/pkg/runtest (cached) ok github.com/google/syzkaller/pkg/serializer (cached) ok github.com/google/syzkaller/pkg/signal (cached) ok github.com/google/syzkaller/pkg/stats (cached) 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 (cached) ok github.com/google/syzkaller/syz-fuzzer (cached) ok github.com/google/syzkaller/syz-hub (cached) ok github.com/google/syzkaller/syz-hub/state (cached) ok github.com/google/syzkaller/syz-manager (cached) ok github.com/google/syzkaller/syz-verifier (cached) 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 (cached) 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 (cached) ok github.com/google/syzkaller/vm/isolated (cached) ok github.com/google/syzkaller/vm/proxyapp (cached) ok github.com/google/syzkaller/vm/vmimpl (cached) FAIL