? 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/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/iset [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 [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/darwin [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/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/netbsd/gen [no test files] ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ok github.com/google/syzkaller/executor 13.897s ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 1.673s 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/syz-runner [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-check [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-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-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ok github.com/google/syzkaller/pkg/compiler 12.768s 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-mutate [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [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-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ? 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/gvisor [no test files] ? github.com/google/syzkaller/vm/gce [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 (14.23s) --- FAIL: TestGenerate/test/64 (0.00s) testutil.go:33: seed=1711752451108731234 testutil.go:33: seed=1711752451112667199 --- FAIL: TestGenerate/test/64/6 (0.90s) 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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :304:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1093507503 -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 (0.92s) 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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); do_sandbox_none(); return 0; } :291:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2759391105 -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 (0.97s) 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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :304:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1182841974 -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/5 (0.75s) 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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); 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; } :306:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1981722299 -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.03s) 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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :304:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3771435576 -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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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) { inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); syscall(SYS_mutate1); *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); syscall(SYS_breaks_returns); memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); syz_sleep_ms(/*ms=*/0x951a); *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); syz_errno(/*v=*/0xc9); memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); syz_exit(/*status=*/0x7cd); syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); syz_sleep_ms(/*ms=*/0x57); syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :152:2: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2252664102 -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/12 (1.23s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: test$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 18; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); static void loop(void) { execute_one(); } void execute_call(int call) { switch (call) { case 0: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :306:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2275438370 -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/4 (0.92s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: test$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :304:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2403532406 -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/2 (1.19s) csource_test.go:150: opts: {Threaded:true Repeat:false RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: test$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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 loop(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); } void execute_call(int call) { switch (call) { case 0: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); 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, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3496233544 -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.00s) 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$produce_subtype_of_common() (fail_nth: 1) mutate1() (async) test$end1(&(0x7f0000000000)={0xe}) (rerun: 4) test$text_x86_64(&(0x7f0000000040)="b805000000b9e15bcbfa0f01d92ef3420fc7b58074000066bad004b09eee650f66b5f46a928d0fab9700000080b805000000b9eed4c8ed0f01d9c463356cea0926650fc779000fc7acf70c000000660feafd", 0x52) test$text_x86_64(&(0x7f00000000c0)="430f01cbb926030000b8fb000000ba000000000f3066400f38dd1266baf80cb89c476884ef66bafc0cb80e000000efc744240004000000c74424021b25d628c7442406000000000f0114244d0fc75b0066f7bcc36bea14b866baf80cb81da6d280ef66bafc0cecc744240095580000c7442402bb000000c7442406000000000f011c240fc3b5f600c0fe", 0x8a) test$length6(&(0x7f0000000180)={[0xd32, 0x40, 0x400, 0x1], 0x4}) breaks_returns() test$text_x86_64(&(0x7f00000001c0)="66b829018ee00f21a00f015b00c401f17dc0400f3248b800700000000000000f23c00f21f835020005000f23f8c744240004000100c7442402cca9aed3c7442406000000000f011424c4034d69ac84090000000048b81c50bdc2898e41140f23d80f21f835c00000e00f23f8c40179172a", 0x71) syz_sleep_ms(0x951a) test$end1(&(0x7f0000000240)={0xe, 0x42, 0x1}) syz_compare(&(0x7f0000000000)='\x00', 0x1, &(0x7f0000000040)=@align0={0x3ff, 0xffffff9c, 0x0, 0xc77b, 0x6}, 0x18) syz_compare_int$2(0x2, 0x7, 0x4) syz_errno(0xc9) syz_execute_func(&(0x7f0000000080)="e1c79d81050e6aa84191cb2ef515570104302a656dc4384ea7f08ed638ec9a74cd14908894358f4db985c870fea6066f0c01") syz_exit(0x7cd) syz_mmap(&(0x7f0000ffb000/0x3000)=nil, 0x3000) syz_sleep_ms(0x57) syz_test_fuzzer1(0x8, 0xb, 0xd) 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_breaks_returns #define SYS_breaks_returns 0 #endif #ifndef SYS_mutate1 #define SYS_mutate1 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: inject_fault(1); syscall(SYS_test, 0, 0, 0, 0, 0, 0); break; case 1: syscall(SYS_mutate1); break; case 2: *(uint16_t*)0x20000000 = htobe16(0xe); *(uint32_t*)0x20000002 = htobe32(0x42); *(uint64_t*)0x20000006 = htobe64(0); syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*a0=*/0x20000000ul, 0, 0, 0, 0, 0); } } break; case 3: memcpy((void*)0x20000040, "\xb8\x05\x00\x00\x00\xb9\xe1\x5b\xcb\xfa\x0f\x01\xd9\x2e\xf3\x42\x0f\xc7\xb5\x80\x74\x00\x00\x66\xba\xd0\x04\xb0\x9e\xee\x65\x0f\x66\xb5\xf4\x6a\x92\x8d\x0f\xab\x97\x00\x00\x00\x80\xb8\x05\x00\x00\x00\xb9\xee\xd4\xc8\xed\x0f\x01\xd9\xc4\x63\x35\x6c\xea\x09\x26\x65\x0f\xc7\x79\x00\x0f\xc7\xac\xf7\x0c\x00\x00\x00\x66\x0f\xea\xfd", 82); syscall(SYS_test, /*a0=*/0x20000040ul, /*a1=*/0x52, 0, 0, 0, 0); break; case 4: memcpy((void*)0x200000c0, "\x43\x0f\x01\xcb\xb9\x26\x03\x00\x00\xb8\xfb\x00\x00\x00\xba\x00\x00\x00\x00\x0f\x30\x66\x40\x0f\x38\xdd\x12\x66\xba\xf8\x0c\xb8\x9c\x47\x68\x84\xef\x66\xba\xfc\x0c\xb8\x0e\x00\x00\x00\xef\xc7\x44\x24\x00\x04\x00\x00\x00\xc7\x44\x24\x02\x1b\x25\xd6\x28\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\x4d\x0f\xc7\x5b\x00\x66\xf7\xbc\xc3\x6b\xea\x14\xb8\x66\xba\xf8\x0c\xb8\x1d\xa6\xd2\x80\xef\x66\xba\xfc\x0c\xec\xc7\x44\x24\x00\x95\x58\x00\x00\xc7\x44\x24\x02\xbb\x00\x00\x00\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x1c\x24\x0f\xc3\xb5\xf6\x00\xc0\xfe", 138); syscall(SYS_test, /*a0=*/0x200000c0ul, /*a1=*/0x8a, 0, 0, 0, 0); break; case 5: *(uint16_t*)0x20000180 = 0xd32; *(uint16_t*)0x20000182 = 0x40; *(uint16_t*)0x20000184 = 0x400; *(uint16_t*)0x20000186 = 1; *(uint16_t*)0x20000188 = 4; syscall(SYS_test, /*a0=*/0x20000180ul, 0, 0, 0, 0, 0); break; case 6: syscall(SYS_breaks_returns); break; case 7: memcpy((void*)0x200001c0, "\x66\xb8\x29\x01\x8e\xe0\x0f\x21\xa0\x0f\x01\x5b\x00\xc4\x01\xf1\x7d\xc0\x40\x0f\x32\x48\xb8\x00\x70\x00\x00\x00\x00\x00\x00\x0f\x23\xc0\x0f\x21\xf8\x35\x02\x00\x05\x00\x0f\x23\xf8\xc7\x44\x24\x00\x04\x00\x01\x00\xc7\x44\x24\x02\xcc\xa9\xae\xd3\xc7\x44\x24\x06\x00\x00\x00\x00\x0f\x01\x14\x24\xc4\x03\x4d\x69\xac\x84\x09\x00\x00\x00\x00\x48\xb8\x1c\x50\xbd\xc2\x89\x8e\x41\x14\x0f\x23\xd8\x0f\x21\xf8\x35\xc0\x00\x00\xe0\x0f\x23\xf8\xc4\x01\x79\x17\x2a", 113); syscall(SYS_test, /*a0=*/0x200001c0ul, /*a1=*/0x71, 0, 0, 0, 0); break; case 8: syz_sleep_ms(/*ms=*/0x951a); break; case 9: *(uint16_t*)0x20000240 = htobe16(0xe); *(uint32_t*)0x20000242 = htobe32(0x42); *(uint64_t*)0x20000246 = htobe64(1); syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memset((void*)0x20000000, 0, 1); *(uint16_t*)0x20000040 = 0x3ff; *(uint32_t*)0x20000044 = 0xffffff9c; *(uint8_t*)0x20000048 = 0; *(uint16_t*)0x2000004a = 0xc77b; *(uint64_t*)0x20000050 = 6; syz_compare(/*want=*/0x20000000, /*want_len=*/1, /*got=*/0x20000040, /*got_len=*/0x18); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/7, /*v1=*/4, 0, 0); break; case 12: syz_errno(/*v=*/0xc9); break; case 13: memcpy((void*)0x20000080, "\xe1\xc7\x9d\x81\x05\x0e\x6a\xa8\x41\x91\xcb\x2e\xf5\x15\x57\x01\x04\x30\x2a\x65\x6d\xc4\x38\x4e\xa7\xf0\x8e\xd6\x38\xec\x9a\x74\xcd\x14\x90\x88\x94\x35\x8f\x4d\xb9\x85\xc8\x70\xfe\xa6\x06\x6f\x0c\x01", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0x7cd); break; case 15: syz_mmap(/*addr=*/0x20ffb000, /*len=*/0x3000); break; case 16: syz_sleep_ms(/*ms=*/0x57); break; case 17: syz_test_fuzzer1(/*a=*/8, /*b=*/0xb, /*c=*/0xd); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :304:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_test, 0, 0, 0, 0, 0, 0); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor1664256974 -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 (0.93s) csource_test.go:148: --- FAIL: TestGenerate/test/64/8 (1.37s) csource_test.go:148: --- FAIL: TestGenerate/test/64/14 (1.37s) csource_test.go:148: --- FAIL: TestGenerate/test/64/7 (1.22s) csource_test.go:148: FAIL FAIL github.com/google/syzkaller/pkg/csource 23.192s 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