? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/dashboard/app 0.076s ok github.com/google/syzkaller/executor 1.975s ok github.com/google/syzkaller/pkg/asset (cached) ok github.com/google/syzkaller/pkg/ast 0.605s ok github.com/google/syzkaller/pkg/auth (cached) ? github.com/google/syzkaller/pkg/debugtracer [no test files] ? github.com/google/syzkaller/pkg/gce [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/html [no test files] ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ? github.com/google/syzkaller/pkg/rpctype [no test files] ? github.com/google/syzkaller/pkg/signal [no test files] ? github.com/google/syzkaller/pkg/testutil [no test files] ? github.com/google/syzkaller/pkg/tools [no test files] ok github.com/google/syzkaller/pkg/bisect 19.101s ok github.com/google/syzkaller/pkg/build 10.136s ok github.com/google/syzkaller/pkg/compiler 3.949s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/cover 42.777s ok github.com/google/syzkaller/pkg/cover/backend 0.592s --- FAIL: TestGenerate (26.42s) --- FAIL: TestGenerate/fuchsia/amd64 (0.07s) testutil.go:33: seed=1680543777897455708 --- FAIL: TestGenerate/fuchsia/amd64/14 (0.25s) csource_test.go:133: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:2 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); for (procid = 0; procid < 2; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :290:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor1306579320 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/9 (0.22s) csource_test.go:133: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :286:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor3807191493 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/12 (0.23s) csource_test.go:133: 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 UseTmpDir:true HandleSegv:false Repro:true Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :288:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2388709621 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/10 (0.22s) csource_test.go:133: 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 UseTmpDir:false HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); do_sandbox_none(); return 0; } :274:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor4120843881 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/13 (0.24s) csource_test.go:133: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:true LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { fprintf(stderr, "### start\n"); int i, call, thread; for (call = 0; call < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); fprintf(stderr, "### call=0 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); fprintf(stderr, "### call=1 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); fprintf(stderr, "### call=2 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); fprintf(stderr, "### call=3 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); fprintf(stderr, "### call=4 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); fprintf(stderr, "### call=5 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 6: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); fprintf(stderr, "### call=6 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); fprintf(stderr, "### call=7 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 8: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); fprintf(stderr, "### call=8 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); fprintf(stderr, "### call=9 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); res = -1; errno = EFAULT; res = syz_execute_func(0x20000000); fprintf(stderr, "### call=10 errno=%u\n", res == -1 ? errno : 0); break; case 11: res = -1; errno = EFAULT; res = syz_future_time(1); fprintf(stderr, "### call=11 errno=%u\n", res == -1 ? errno : 0); break; case 12: res = -1; errno = EFAULT; res = syz_job_default(); fprintf(stderr, "### call=12 errno=%u\n", res == -1 ? errno : 0); break; case 13: res = -1; errno = EFAULT; res = syz_mmap(0x20ffd000, 0x2000); fprintf(stderr, "### call=13 errno=%u\n", res == -1 ? errno : 0); break; case 14: res = -1; errno = EFAULT; res = syz_process_self(); fprintf(stderr, "### call=14 errno=%u\n", res == -1 ? errno : 0); break; case 15: res = -1; errno = EFAULT; res = syz_thread_self(); fprintf(stderr, "### call=15 errno=%u\n", res == -1 ? errno : 0); break; case 16: res = -1; errno = EFAULT; res = syz_vmar_root_self(); fprintf(stderr, "### call=16 errno=%u\n", res == -1 ? errno : 0); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :290:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor1690815454 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/7 (0.25s) csource_test.go:133: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:0 Slowdown:1 Sandbox: SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); loop(); return 0; } :280:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2851060499 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/8 (0.20s) csource_test.go:133: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :286:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor974773081 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/0 (0.29s) csource_test.go:133: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void use_temporary_dir(void) { char tmpdir_template[] = "/tmp/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() { } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) static long syz_execute_func(volatile long text) { ((void (*)(void))(text))(); return 0; } static void execute_one(void); static void loop(void) { execute_one(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_one(void) { intptr_t res = 0; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); syz_future_time(1); syz_job_default(); syz_mmap(0x20ffd000, 0x2000); syz_process_self(); syz_thread_self(); syz_vmar_root_self(); } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :151:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor3862824938 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/6 (0.16s) csource_test.go:133: 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 UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :286:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor1962070177 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/4 (0.19s) csource_test.go:133: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_create$fuchsia_io_File(0x0, &(0x7f0000000000)=0x0, &(0x7f0000000040)=0x0) (fail_nth: 1) zx_channel_call_etc(0x0, 0x33d2, 0x0, &(0x7f0000000300)={&(0x7f00000000c0)="31e8f2b5eee7a2ab5b27127bb076c508922fc23db5e28c55d60095d6ce92496278ae2352b30ee0bf39cee0bffb8ea4df80630d267e7505d7d74dd922b8ce4205479d5b1361b75782238cd4eb2735e66845478e7d64d185c1e775318b75dbd9c4b21dae108ded8d332898341e52c92e611cbd244af6229f98675c2b255fe368d6cbd4f15688d9274af1265ce0adc01f24ce9114595e422849ebdc25d20deea9", &(0x7f0000000180)=[0x0], &(0x7f00000001c0)=""/240, &(0x7f00000002c0)=[0x0, 0x0, 0x0], 0x9f, 0x1, 0xf0, 0x3}, &(0x7f0000000340), &(0x7f0000000380)) (async) zx_channel_write$fuchsia_io_FileClone(r0, 0x0, &(0x7f0000000080)={{}, 0x0, 0xffffffff}, 0x18, &(0x7f00000003c0)={r3}, 0x4) (rerun: 4) zx_handle_duplicate(r1, 0x8000, &(0x7f0000000400)=0x0) zx_clock_get_details(r2, 0x400000000000000, &(0x7f0000000440)={0x0, 0x0}) zx_channel_call$fuchsia_io_FileGetFlags(r4, 0x0, r5, &(0x7f0000010580)={&(0x7f00000004c0), &(0x7f0000000500), &(0x7f0000000540), &(0x7f0000010540), 0x10, 0x0, 0x10000}, &(0x7f00000105c0), &(0x7f0000010600)) zx_bti_release_quarantine(r3) zx_object_set_property$ZX_PROP_NAME(r1, 0x3, &(0x7f0000010640)="05321badf83e5998f476af3a8e68", 0xe) zx_channel_create(0x0, &(0x7f0000010680)=0x0, &(0x7f00000106c0)) zx_channel_call$fuchsia_io_DirectoryGetAttr(r6, 0x0, r5, &(0x7f00000207c0)={&(0x7f0000010700), &(0x7f0000010740), &(0x7f0000010780), &(0x7f0000020780), 0x10, 0x0, 0x10000}, &(0x7f0000020800), &(0x7f0000020840)) syz_execute_func(&(0x7f0000000000)="2e640f93f066660f002bc4235d686b46fac4010e59d826dbe0c4e16c55f83e660fc43d0000000072f2490f2a7f00f0f650c6d926") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffd000/0x2000)=nil, 0x2000) syz_process_self() syz_thread_self() syz_vmar_root_self() csource_test.go:134: failed to build program: // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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[] = "/tmp/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 { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) usleep(200); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout_ms) { uint64_t start = current_time_ms(); for (;;) { if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; if (current_time_ms() - start > timeout_ms) return 0; usleep(200); } } long syz_mmap(size_t addr, size_t size) { zx_handle_t root = zx_vmar_root_self(); zx_info_vmar_t info; zx_status_t status = zx_object_get_info(root, ZX_INFO_VMAR, &info, sizeof(info), 0, 0); if (status != ZX_OK) { return status; } zx_handle_t vmo; status = zx_vmo_create(size, 0, &vmo); if (status != ZX_OK) { return status; } uintptr_t mapped_addr; status = zx_vmar_map(root, ZX_VM_FLAG_SPECIFIC_OVERWRITE | ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE, addr - info.base, vmo, 0, size, &mapped_addr); zx_status_t close_vmo_status = zx_handle_close(vmo); if (close_vmo_status != ZX_OK) { } return status; } static long syz_process_self(void) { return zx_process_self(); } static long syz_thread_self(void) { return zx_thread_self(); } static long syz_vmar_root_self(void) { return zx_vmar_root_self(); } static long syz_job_default(void) { return zx_job_default(); } static long syz_future_time(volatile long when) { zx_time_t delta_ms = 10000; switch (when) { case 0: delta_ms = 5; break; case 1: delta_ms = 30; break; } zx_time_t now = 0; zx_clock_read(ZX_CLOCK_MONOTONIC, &now); return now + delta_ms * 1000 * 1000; } static void loop(); static int do_sandbox_none(void) { loop(); return 0; } #define CAST(f) ({void* p = (void*)f; p; }) 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 < 17; 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(); } uint64_t r[7] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20000000, 0x20000040); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20000000; r[1] = *(uint32_t*)0x20000040; } break; case 1: *(uint64_t*)0x20000300 = 0x200000c0; memcpy((void*)0x200000c0, "\x31\xe8\xf2\xb5\xee\xe7\xa2\xab\x5b\x27\x12\x7b\xb0\x76\xc5\x08\x92\x2f\xc2\x3d\xb5\xe2\x8c\x55\xd6\x00\x95\xd6\xce\x92\x49\x62\x78\xae\x23\x52\xb3\x0e\xe0\xbf\x39\xce\xe0\xbf\xfb\x8e\xa4\xdf\x80\x63\x0d\x26\x7e\x75\x05\xd7\xd7\x4d\xd9\x22\xb8\xce\x42\x05\x47\x9d\x5b\x13\x61\xb7\x57\x82\x23\x8c\xd4\xeb\x27\x35\xe6\x68\x45\x47\x8e\x7d\x64\xd1\x85\xc1\xe7\x75\x31\x8b\x75\xdb\xd9\xc4\xb2\x1d\xae\x10\x8d\xed\x8d\x33\x28\x98\x34\x1e\x52\xc9\x2e\x61\x1c\xbd\x24\x4a\xf6\x22\x9f\x98\x67\x5c\x2b\x25\x5f\xe3\x68\xd6\xcb\xd4\xf1\x56\x88\xd9\x27\x4a\xf1\x26\x5c\xe0\xad\xc0\x1f\x24\xce\x91\x14\x59\x5e\x42\x28\x49\xeb\xdc\x25\xd2\x0d\xee\xa9", 159); *(uint64_t*)0x20000308 = 0x20000180; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000310 = 0x200001c0; *(uint64_t*)0x20000318 = 0x200002c0; *(uint32_t*)0x20000320 = 0x9f; *(uint32_t*)0x20000324 = 1; *(uint32_t*)0x20000328 = 0xf0; *(uint32_t*)0x2000032c = 3; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); if (res == ZX_OK) { r[2] = *(uint32_t*)0x200002c4; r[3] = *(uint32_t*)0x200002c8; } break; case 2: *(uint32_t*)0x20000080 = 0; memset((void*)0x20000084, 0, 3); *(uint8_t*)0x20000087 = 1; *(uint64_t*)0x20000088 = 0x17fe6a4c00000000; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000094 = -1; *(uint32_t*)0x200003c0 = r[3]; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); { int i; for(i = 0; i < 4; i++) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(r[0], 0, 0x20000080, 0x18, 0x200003c0, 4); } } break; case 3: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_handle_duplicate))(r[1], 0x8000, 0x20000400); if (res == ZX_OK) r[4] = *(uint32_t*)0x20000400; break; case 4: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_clock_get_details))(r[2], 0x400000000000000, 0x20000440); if (res == ZX_OK) r[5] = *(uint64_t*)0x20000448; break; case 5: *(uint64_t*)0x20010580 = 0x200004c0; *(uint32_t*)0x200004c0 = 0; memset((void*)0x200004c4, 0, 3); *(uint8_t*)0x200004c7 = 1; *(uint64_t*)0x200004c8 = 0x6416a3f600000000; *(uint64_t*)0x20010588 = 0x20000500; *(uint64_t*)0x20010590 = 0x20000540; *(uint64_t*)0x20010598 = 0x20010540; *(uint32_t*)0x200105a0 = 0x10; *(uint32_t*)0x200105a4 = 0; *(uint32_t*)0x200105a8 = 0x10000; *(uint32_t*)0x200105ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[4], 0, r[5], 0x20010580, 0x200105c0, 0x20010600); break; case 6: ((intptr_t(*)(intptr_t))CAST(zx_bti_release_quarantine))(r[3]); break; case 7: memcpy((void*)0x20010640, "\x05\x32\x1b\xad\xf8\x3e\x59\x98\xf4\x76\xaf\x3a\x8e\x68", 14); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_set_property))(r[1], 3, 0x20010640, 0xe); break; case 8: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_channel_create))(0, 0x20010680, 0x200106c0); if (res == ZX_OK) r[6] = *(uint32_t*)0x20010680; break; case 9: *(uint64_t*)0x200207c0 = 0x20010700; *(uint32_t*)0x20010700 = 0; memset((void*)0x20010704, 0, 3); *(uint8_t*)0x20010707 = 1; *(uint64_t*)0x20010708 = 0x4585e7c800000000; *(uint64_t*)0x200207c8 = 0x20010740; *(uint64_t*)0x200207d0 = 0x20010780; *(uint64_t*)0x200207d8 = 0x20020780; *(uint32_t*)0x200207e0 = 0x10; *(uint32_t*)0x200207e4 = 0; *(uint32_t*)0x200207e8 = 0x10000; *(uint32_t*)0x200207ec = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[6], 0, r[5], 0x200207c0, 0x20020800, 0x20020840); break; case 10: memcpy((void*)0x20000000, "\x2e\x64\x0f\x93\xf0\x66\x66\x0f\x00\x2b\xc4\x23\x5d\x68\x6b\x46\xfa\xc4\x01\x0e\x59\xd8\x26\xdb\xe0\xc4\xe1\x6c\x55\xf8\x3e\x66\x0f\xc4\x3d\x00\x00\x00\x00\x72\xf2\x49\x0f\x2a\x7f\x00\xf0\xf6\x50\xc6\xd9\x26", 52); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffd000, 0x2000); break; case 14: syz_process_self(); break; case 15: syz_thread_self(); break; case 16: syz_vmar_root_self(); break; } } int main(void) { syz_mmap(0x20000000, 0x1000000); setup_fault(); use_temporary_dir(); do_sandbox_none(); return 0; } :286:81: error: use of undeclared identifier 'zx_channel_call_etc' res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(0, 0x33d2, 0, 0x20000300, 0x20000340, 0x20000380); ^ 1 error generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor792852555 -DGOOS_fuchsia=1 -DGOARCH_amd64=1 -DHOSTGOOS_linux=1 -x c - -Wno-deprecated -target x86_64-fuchsia -ldriver -lfdio -lzircon --sysroot /syzkaller/shared/fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot -I /syzkaller/shared/fuchsia/sdk/lib/fdio/include -I /syzkaller/shared/fuchsia/zircon/system/ulib/fidl/include -I /syzkaller/shared/fuchsia/src/lib/ddk/include -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.device.manager -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.nand -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.power.statecontrol -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/sdk/fidl/fuchsia.hardware.usb.peripheral -I /syzkaller/shared/fuchsia/out/x64/fidling/gen/zircon/vdso/zx -L /syzkaller/shared/fuchsia/out/x64/x64-shared -O2 -pthread -Wall -Werror -Wparentheses -Wunused-const-variable -Wframe-larger-than=16384 -Wno-array-bounds -Wno-unused-command-line-argument] --- FAIL: TestGenerate/fuchsia/amd64/5 (0.17s) csource_test.go:131: --- FAIL: TestGenerate/fuchsia/amd64/3 (0.22s) csource_test.go:131: --- FAIL: TestGenerate/fuchsia/amd64/1 (0.22s) csource_test.go:131: --- FAIL: TestGenerate/fuchsia/amd64/2 (0.24s) csource_test.go:131: FAIL FAIL github.com/google/syzkaller/pkg/csource 38.548s ok github.com/google/syzkaller/pkg/db (cached) ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/host 16.575s ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/image 1.985s ok github.com/google/syzkaller/pkg/instance 3.444s ok github.com/google/syzkaller/pkg/ipc 37.418s ok github.com/google/syzkaller/pkg/kconfig 0.740s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig 2.779s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 17.230s ok github.com/google/syzkaller/pkg/repro 2.926s ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/akaros [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] ok github.com/google/syzkaller/pkg/runtest 62.075s ok github.com/google/syzkaller/pkg/serializer (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 0.011s ok github.com/google/syzkaller/pkg/subsystem/lists 0.093s 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 11.135s ok github.com/google/syzkaller/prog/test (cached) ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ? github.com/google/syzkaller/syz-runner [no test files] ? 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] ok github.com/google/syzkaller/sys/linux 0.124s ok github.com/google/syzkaller/sys/openbsd (cached) ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-imagegen [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-prog2c [no test files] ? github.com/google/syzkaller/tools/syz-query-subsystems [no test files] ? github.com/google/syzkaller/tools/syz-reporter [no test files] ? github.com/google/syzkaller/tools/syz-repro [no test files] ? github.com/google/syzkaller/tools/syz-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-testbed [no test files] ? github.com/google/syzkaller/tools/syz-testbuild [no test files] ? github.com/google/syzkaller/tools/syz-trace2syz [no test files] ok github.com/google/syzkaller/syz-ci 1.796s ok github.com/google/syzkaller/syz-fuzzer 0.508s ok github.com/google/syzkaller/syz-hub 0.021s ok github.com/google/syzkaller/syz-hub/state 0.076s ok github.com/google/syzkaller/syz-manager 1.925s ok github.com/google/syzkaller/syz-verifier 1.666s 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-trace2syz/parser 0.008s ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 0.142s ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/cuttlefish [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ? github.com/google/syzkaller/vm/kvm [no test files] ? github.com/google/syzkaller/vm/odroid [no test files] ? github.com/google/syzkaller/vm/proxyapp/mocks [no test files] ? github.com/google/syzkaller/vm/proxyapp/proxyrpc [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ? github.com/google/syzkaller/vm/starnix [no test files] ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] ok github.com/google/syzkaller/vm 9.475s ok github.com/google/syzkaller/vm/isolated 1.428s ok github.com/google/syzkaller/vm/proxyapp 3.796s ok github.com/google/syzkaller/vm/vmimpl 1.461s FAIL