? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/dashboard/app 0.317s ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/gcs [no test files] ? github.com/google/syzkaller/pkg/hash [no test files] ? github.com/google/syzkaller/pkg/html/pages [no test files] ? github.com/google/syzkaller/pkg/ifuzz/iset [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ok github.com/google/syzkaller/executor 23.726s ok github.com/google/syzkaller/pkg/asset 0.902s ok github.com/google/syzkaller/pkg/ast 1.598s ok github.com/google/syzkaller/pkg/auth (cached) ? 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 [no test files] ? github.com/google/syzkaller/sys/darwin/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? 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-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-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] ? github.com/google/syzkaller/tools/syz-lore [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-reprolist [no test files] ? github.com/google/syzkaller/tools/syz-runtest [no test files] ? github.com/google/syzkaller/tools/syz-showprio [no test files] ? github.com/google/syzkaller/tools/syz-stress [no test files] ? github.com/google/syzkaller/tools/syz-symbolize [no test files] ? github.com/google/syzkaller/tools/syz-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] ok github.com/google/syzkaller/pkg/bisect 233.764s ok github.com/google/syzkaller/pkg/bisect/minimize (cached) ok github.com/google/syzkaller/pkg/build 9.609s ok github.com/google/syzkaller/pkg/compiler 27.018s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/corpus 1.717s ok github.com/google/syzkaller/pkg/cover 0.356s ok github.com/google/syzkaller/pkg/cover/backend 1.968s --- FAIL: TestGenerate (60.45s) --- FAIL: TestGenerate/test/64 (0.01s) testutil.go:33: seed=1712130650823003602 testutil.go:33: seed=1712130650830281549 --- FAIL: TestGenerate/test/64/0 (1.45s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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) { memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); syz_errno(/*v=*/5); memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); syz_exit(/*status=*/0xf5a6); syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); syz_sleep_ms(/*ms=*/0x100000001); syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :180:2: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor716471419 -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 (2.27s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :332:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3842886609 -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 (2.06s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :332:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor4032018690 -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 (2.54s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :326:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2575953651 -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 (2.74s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :334:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3855812176 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/6 (2.78s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :332:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2522652636 -DGOOS_test=1 -DGOARCH_64=1 -DHOSTGOOS_openbsd=1 -x c - -m64 -lutil -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-but-set-variable -Wno-unused-command-line-argument -no-pie -fno-exceptions] --- FAIL: TestGenerate/test/64/8 (0.95s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:-9223372036854775808 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :332:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2633543748 -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 (2.39s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :332:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3048811071 -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 (1.95s) 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: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); 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; } :334:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor3054722829 -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 (2.64s) csource_test.go:150: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:false HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: serialize2(&(0x7f0000000000)="2bee9cc22e8f25e5563b6b70d50feceb4845afe22f2b8e350b1c439892d43eddcbe032a3b434f19f3e8adaa41ff8adeab30546426041bc36f5234cdbc8de4b78d04d8bfe71adab6987a87243660f6bd7c8f8b839f2371d99748fe57afe0d413bdd21edc42b4e132cc6320e50aa94f0b43b8e651690b6b2f25e9fd79f1950194ef037e412a22a8784346887ae0bba457e8bc02a1c851916c14a05c64dddd200519c44b31430c745d4f5907cd8ef39a84cc05b5e958cb48f646b5a77e320c2a576edbfd73d1aeb337cb5889e8e8d4778cc2df084e506dd0ec0b5c01dd533922c9943bb3b3da76347fce6ba4655d32bc148ae9fc247f708d7b4cdacb95946a4d0") (fail_nth: 1) test$opt2(&(0x7f0000ffb000/0x3000)=nil) (async) test$vma0(&(0x7f0000ffc000/0x1000)=nil, 0x1000, &(0x7f0000ffb000/0x5000)=nil, 0x5000, &(0x7f0000ff7000/0x9000)=nil, 0x9000) (rerun: 4) test$opt2(0x0) test$csum_ipv6_tcp(&(0x7f0000000100)={{"3f6962f79fa12e0732f74b4fa462ad89", "09447c3d5706b231de69b5502eb65465"}, {{}, "401a1c6af442e92d441e967e66fab34f4ad23afe30fe55a91919ec04e72ca88186e3c63dff4ec903a003ce3bca24a76a46a0c2277eb7622b476245061530d0b8f447109bd65b98584e7a6343f0c0faf4b2cfcddcd14ad2d71ebeff38c8436850f40c029ea805d86df0e329f555a1bdf9c3aaca9f7b22450c7c1f997e22429191a9e2814bf50d333f7497dc123848fb504f30aef3b550819419259b25d3931d6cadf84165b5831a561808e0311295b875a3c2ce9f40e5a099e44b93782ef2d55866f0eb1be5ff411480654350bd177caf5c9917be326e8006d3d13eb48b9b5a63d653b8cb855d9c8b7728d3bd1d882ee735"}}) test$length10(&(0x7f0000ffc000/0x2000)=nil, 0x2000, 0x2000, 0x1000, 0x800) syz_mmap(&(0x7f0000ffa000/0x3000)=nil, 0x3000) test$vma0(&(0x7f0000ffb000/0x2000)=nil, 0x2000, &(0x7f0000ffa000/0x5000)=nil, 0x5000, &(0x7f0000ff8000/0x7000)=nil, 0x7000) test$length10(&(0x7f0000ff9000/0x1000)=nil, 0x1000, 0x1000, 0x800, 0x400) test$length9(&(0x7f0000000240)={&(0x7f0000ffb000/0x2000)=nil, 0x2000}) syz_compare(&(0x7f0000000000)='%{$\\\'\x00', 0x6, &(0x7f0000000040)=@bf11={0x2b, {0x7, 0x3f, 0x7, 0x7, 0x3}}, 0x8) syz_compare_int$2(0x2, 0xf4, 0x8000) syz_errno(0x5) syz_execute_func(&(0x7f0000000080)="48a812ca8f57b0365661b7f8366e0b10e0e4e3f95ab50f77088268f00814545f902f5ed37293b0503015a0316948fbd16443") syz_exit(0xf5a6) syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) syz_sleep_ms(0x100000001) syz_test_fuzzer1(0x4, 0x0, 0x7) csource_test.go:151: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_serialize2 #define SYS_serialize2 0 #endif #ifndef SYS_test #define SYS_test 0 #endif static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static int inject_fault(int nth) { return 0; } static void setup_fault() { } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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: memcpy((void*)0x20000000, "\x2b\xee\x9c\xc2\x2e\x8f\x25\xe5\x56\x3b\x6b\x70\xd5\x0f\xec\xeb\x48\x45\xaf\xe2\x2f\x2b\x8e\x35\x0b\x1c\x43\x98\x92\xd4\x3e\xdd\xcb\xe0\x32\xa3\xb4\x34\xf1\x9f\x3e\x8a\xda\xa4\x1f\xf8\xad\xea\xb3\x05\x46\x42\x60\x41\xbc\x36\xf5\x23\x4c\xdb\xc8\xde\x4b\x78\xd0\x4d\x8b\xfe\x71\xad\xab\x69\x87\xa8\x72\x43\x66\x0f\x6b\xd7\xc8\xf8\xb8\x39\xf2\x37\x1d\x99\x74\x8f\xe5\x7a\xfe\x0d\x41\x3b\xdd\x21\xed\xc4\x2b\x4e\x13\x2c\xc6\x32\x0e\x50\xaa\x94\xf0\xb4\x3b\x8e\x65\x16\x90\xb6\xb2\xf2\x5e\x9f\xd7\x9f\x19\x50\x19\x4e\xf0\x37\xe4\x12\xa2\x2a\x87\x84\x34\x68\x87\xae\x0b\xba\x45\x7e\x8b\xc0\x2a\x1c\x85\x19\x16\xc1\x4a\x05\xc6\x4d\xdd\xd2\x00\x51\x9c\x44\xb3\x14\x30\xc7\x45\xd4\xf5\x90\x7c\xd8\xef\x39\xa8\x4c\xc0\x5b\x5e\x95\x8c\xb4\x8f\x64\x6b\x5a\x77\xe3\x20\xc2\xa5\x76\xed\xbf\xd7\x3d\x1a\xeb\x33\x7c\xb5\x88\x9e\x8e\x8d\x47\x78\xcc\x2d\xf0\x84\xe5\x06\xdd\x0e\xc0\xb5\xc0\x1d\xd5\x33\x92\x2c\x99\x43\xbb\x3b\x3d\xa7\x63\x47\xfc\xe6\xba\x46\x55\xd3\x2b\xc1\x48\xae\x9f\xc2\x47\xf7\x08\xd7\xb4\xcd\xac\xb9\x59\x46\xa4\xd0", 255); inject_fault(1); syscall(SYS_serialize2, /*a=*/0x20000000ul); break; case 1: syscall(SYS_test, /*a0=*/0x20ffb000ul, 0, 0, 0, 0, 0); break; case 2: syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); { int i; for(i = 0; i < 4; i++) { syscall(SYS_test, /*v0=*/0x20ffc000ul, /*l0=*/0, /*v1=*/0x20ffb000ul, /*l1=*/0x5000, /*v2=*/0x20ff7000ul, /*l2=*/0x9000ul); } } break; case 3: syscall(SYS_test, /*a0=*/0ul, 0, 0, 0, 0, 0); break; case 4: memcpy((void*)0x20000100, "\x3f\x69\x62\xf7\x9f\xa1\x2e\x07\x32\xf7\x4b\x4f\xa4\x62\xad\x89", 16); memcpy((void*)0x20000110, "\x09\x44\x7c\x3d\x57\x06\xb2\x31\xde\x69\xb5\x50\x2e\xb6\x54\x65", 16); *(uint16_t*)0x20000120 = 0; memcpy((void*)0x20000122, "\x40\x1a\x1c\x6a\xf4\x42\xe9\x2d\x44\x1e\x96\x7e\x66\xfa\xb3\x4f\x4a\xd2\x3a\xfe\x30\xfe\x55\xa9\x19\x19\xec\x04\xe7\x2c\xa8\x81\x86\xe3\xc6\x3d\xff\x4e\xc9\x03\xa0\x03\xce\x3b\xca\x24\xa7\x6a\x46\xa0\xc2\x27\x7e\xb7\x62\x2b\x47\x62\x45\x06\x15\x30\xd0\xb8\xf4\x47\x10\x9b\xd6\x5b\x98\x58\x4e\x7a\x63\x43\xf0\xc0\xfa\xf4\xb2\xcf\xcd\xdc\xd1\x4a\xd2\xd7\x1e\xbe\xff\x38\xc8\x43\x68\x50\xf4\x0c\x02\x9e\xa8\x05\xd8\x6d\xf0\xe3\x29\xf5\x55\xa1\xbd\xf9\xc3\xaa\xca\x9f\x7b\x22\x45\x0c\x7c\x1f\x99\x7e\x22\x42\x91\x91\xa9\xe2\x81\x4b\xf5\x0d\x33\x3f\x74\x97\xdc\x12\x38\x48\xfb\x50\x4f\x30\xae\xf3\xb5\x50\x81\x94\x19\x25\x9b\x25\xd3\x93\x1d\x6c\xad\xf8\x41\x65\xb5\x83\x1a\x56\x18\x08\xe0\x31\x12\x95\xb8\x75\xa3\xc2\xce\x9f\x40\xe5\xa0\x99\xe4\x4b\x93\x78\x2e\xf2\xd5\x58\x66\xf0\xeb\x1b\xe5\xff\x41\x14\x80\x65\x43\x50\xbd\x17\x7c\xaf\x5c\x99\x17\xbe\x32\x6e\x80\x06\xd3\xd1\x3e\xb4\x8b\x9b\x5a\x63\xd6\x53\xb8\xcb\x85\x5d\x9c\x8b\x77\x28\xd3\xbd\x1d\x88\x2e\xe7\x35", 241); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000100, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000110, 16); uint32_t csum_1_chunk_2 = 0xf3000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000120, 243); *(uint16_t*)0x20000120 = csum_inet_digest(&csum_1); syscall(SYS_test, /*a0=*/0x20000100ul, 0, 0, 0, 0, 0); break; case 5: syscall(SYS_test, /*a0=*/0x20ffc000ul, /*a1=*/0, /*a2=*/0x2000, /*a3=*/0x1000, /*a4=*/0x800ul, 0); break; case 6: syz_mmap(/*addr=*/0x20ffa000, /*len=*/0x3000); break; case 7: syscall(SYS_test, /*v0=*/0x20ffb000ul, /*l0=*/0, /*v1=*/0x20ffa000ul, /*l1=*/0x5000, /*v2=*/0x20ff8000ul, /*l2=*/0x7000ul); break; case 8: syscall(SYS_test, /*a0=*/0x20ff9000ul, /*a1=*/0, /*a2=*/0x1000, /*a3=*/0x800, /*a4=*/0x400ul, 0); break; case 9: *(uint64_t*)0x20000240 = 0x20ffb000; *(uint64_t*)0x20000248 = 0x2000; syscall(SYS_test, /*a0=*/0x20000240ul, 0, 0, 0, 0, 0); break; case 10: memcpy((void*)0x20000000, "%{$\\\'\000", 6); *(uint8_t*)0x20000040 = 0x2b; *(uint8_t*)0x20000044 = 7; *(uint8_t*)0x20000045 = 0x3f; *(uint8_t*)0x20000046 = 7; STORE_BY_BITMASK(uint32_t, , 0x20000044, 7, 24, 4); STORE_BY_BITMASK(uint32_t, , 0x20000044, 3, 28, 4); syz_compare(/*want=*/0x20000000, /*want_len=*/6, /*got=*/0x20000040, /*got_len=*/8); break; case 11: syz_compare_int(/*n=*/2, /*v0=*/0xf4, /*v1=*/0x8000, 0, 0); break; case 12: syz_errno(/*v=*/5); break; case 13: memcpy((void*)0x20000080, "\x48\xa8\x12\xca\x8f\x57\xb0\x36\x56\x61\xb7\xf8\x36\x6e\x0b\x10\xe0\xe4\xe3\xf9\x5a\xb5\x0f\x77\x08\x82\x68\xf0\x08\x14\x54\x5f\x90\x2f\x5e\xd3\x72\x93\xb0\x50\x30\x15\xa0\x31\x69\x48\xfb\xd1\x64\x43", 50); syz_execute_func(/*text=*/0x20000080); break; case 14: syz_exit(/*status=*/0xf5a6); break; case 15: syz_mmap(/*addr=*/0x20ffc000, /*len=*/0x1000); break; case 16: syz_sleep_ms(/*ms=*/0x100000001); break; case 17: syz_test_fuzzer1(/*a=*/4, /*b=*/0, /*c=*/7); break; } } int main(void) { syz_mmap(/*addr=*/0x20000000, /*len=*/0x1000000); setup_fault(); do_sandbox_none(); return 0; } :319:3: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] syscall(SYS_serialize2, /*a=*/0x20000000ul); ^ 1 error generated. compiler invocation: c++ [-o /tmp/syz-executor2296958651 -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 (1.02s) csource_test.go:148: --- FAIL: TestGenerate/test/64/14 (1.97s) csource_test.go:148: --- FAIL: TestGenerate/test/64/7 (1.85s) csource_test.go:148: --- FAIL: TestGenerate/test/64/13 (1.87s) csource_test.go:148: FAIL FAIL github.com/google/syzkaller/pkg/csource 83.987s 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 91.464s ok github.com/google/syzkaller/pkg/gce 0.261s ok github.com/google/syzkaller/pkg/host 12.287s 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 24.711s ok github.com/google/syzkaller/pkg/ipc 46.577s 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 19.286s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 31.369s ok github.com/google/syzkaller/pkg/repro 16.441s ok github.com/google/syzkaller/pkg/runtest 144.180s 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 86.391s ok github.com/google/syzkaller/syz-fuzzer 1.064s ok github.com/google/syzkaller/syz-hub 1.062s ok github.com/google/syzkaller/syz-hub/state 1.558s ok github.com/google/syzkaller/syz-manager 39.279s ok github.com/google/syzkaller/syz-verifier 18.269s 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 20.256s 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 34.041s ok github.com/google/syzkaller/vm/isolated 18.048s ok github.com/google/syzkaller/vm/proxyapp 21.073s ok github.com/google/syzkaller/vm/vmimpl 15.298s FAIL