? github.com/google/syzkaller/dashboard/dashapi [no test files] ok github.com/google/syzkaller/dashboard/app 0.154s ? 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 [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/x86 [no test files] ? github.com/google/syzkaller/pkg/ifuzz/powerpc/generated [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/gen [no test files] ? github.com/google/syzkaller/pkg/ifuzz/x86/generated [no test files] ? github.com/google/syzkaller/pkg/ipc/ipcconfig [no test files] ? github.com/google/syzkaller/pkg/kcidb [no test files] ? github.com/google/syzkaller/pkg/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] ? github.com/google/syzkaller/sys [no test files] ? github.com/google/syzkaller/sys/akaros [no test files] ? github.com/google/syzkaller/sys/akaros/gen [no test files] ? github.com/google/syzkaller/sys/darwin [no test files] ? github.com/google/syzkaller/sys/darwin/gen [no test files] ? github.com/google/syzkaller/sys/freebsd [no test files] ? github.com/google/syzkaller/sys/freebsd/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia [no test files] ? github.com/google/syzkaller/sys/fuchsia/fidlgen [no test files] ? github.com/google/syzkaller/sys/fuchsia/gen [no test files] ? github.com/google/syzkaller/sys/fuchsia/layout [no test files] ? github.com/google/syzkaller/sys/linux/gen [no test files] ? github.com/google/syzkaller/sys/netbsd/gen [no test files] ? github.com/google/syzkaller/sys/openbsd/gen [no test files] ? github.com/google/syzkaller/sys/syz-extract [no test files] ? github.com/google/syzkaller/sys/syz-sysgen [no test files] ? github.com/google/syzkaller/sys/targets [no test files] ? github.com/google/syzkaller/sys/test [no test files] ? github.com/google/syzkaller/sys/test/gen [no test files] ? github.com/google/syzkaller/sys/trusty [no test files] ? github.com/google/syzkaller/sys/trusty/gen [no test files] ? github.com/google/syzkaller/sys/windows [no test files] ? github.com/google/syzkaller/sys/windows/gen [no test files] ok github.com/google/syzkaller/executor 4.659s ok github.com/google/syzkaller/pkg/asset 0.101s ok github.com/google/syzkaller/pkg/ast 0.605s ok github.com/google/syzkaller/pkg/auth (cached) ? github.com/google/syzkaller/syz-runner [no test files] ? github.com/google/syzkaller/tools/syz-benchcmp [no test files] ? github.com/google/syzkaller/tools/syz-bisect [no test files] ? github.com/google/syzkaller/tools/syz-build [no test files] ? github.com/google/syzkaller/tools/syz-check [no test files] ? github.com/google/syzkaller/tools/syz-cover [no test files] ? github.com/google/syzkaller/tools/syz-crush [no test files] ? github.com/google/syzkaller/tools/syz-db [no test files] ? github.com/google/syzkaller/tools/syz-execprog [no test files] ? github.com/google/syzkaller/tools/syz-expand [no test files] ? github.com/google/syzkaller/tools/syz-fillreports [no test files] ? github.com/google/syzkaller/tools/syz-fmt [no test files] ? github.com/google/syzkaller/tools/syz-hubtool [no test files] ? github.com/google/syzkaller/tools/syz-imagegen [no test files] ? github.com/google/syzkaller/tools/syz-kcidb [no test files] ? github.com/google/syzkaller/tools/syz-lore [no test files] ? github.com/google/syzkaller/tools/syz-make [no test files] ? github.com/google/syzkaller/tools/syz-minconfig [no test files] ? github.com/google/syzkaller/tools/syz-mutate [no test files] ? github.com/google/syzkaller/tools/syz-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] ? github.com/google/syzkaller/tools/syz-tty [no test files] ? github.com/google/syzkaller/tools/syz-upgrade [no test files] ? github.com/google/syzkaller/tools/syz-usbgen [no test files] ? github.com/google/syzkaller/vm/adb [no test files] ? github.com/google/syzkaller/vm/bhyve [no test files] ? github.com/google/syzkaller/vm/cuttlefish [no test files] ? github.com/google/syzkaller/vm/gce [no test files] ? github.com/google/syzkaller/vm/gvisor [no test files] ? github.com/google/syzkaller/vm/kvm [no test files] ? github.com/google/syzkaller/vm/odroid [no test files] ? github.com/google/syzkaller/vm/proxyapp/mocks [no test files] ? github.com/google/syzkaller/vm/proxyapp/proxyrpc [no test files] ? github.com/google/syzkaller/vm/qemu [no test files] ? github.com/google/syzkaller/vm/starnix [no test files] ? github.com/google/syzkaller/vm/vmm [no test files] ? github.com/google/syzkaller/vm/vmware [no test files] ok github.com/google/syzkaller/pkg/bisect 26.284s ok github.com/google/syzkaller/pkg/build 12.373s ok github.com/google/syzkaller/pkg/compiler 4.324s ok github.com/google/syzkaller/pkg/config (cached) ok github.com/google/syzkaller/pkg/cover 50.286s ok github.com/google/syzkaller/pkg/cover/backend 0.468s --- FAIL: TestGenerate (36.54s) --- FAIL: TestGenerate/fuchsia/amd64 (0.09s) testutil.go:33: seed=1682383082720379023 --- FAIL: TestGenerate/fuchsia/amd64/12 (0.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :317: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :321:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor3660911611 -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.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :309: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :313:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2575642992 -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.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); fprintf(stderr, "### call=0 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); fprintf(stderr, "### call=1 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); fprintf(stderr, "### call=3 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 4: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); fprintf(stderr, "### call=4 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 5: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); fprintf(stderr, "### call=5 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); fprintf(stderr, "### call=6 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 7: res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); fprintf(stderr, "### call=7 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 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[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); fprintf(stderr, "### call=8 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; res = -1; errno = EFAULT; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); fprintf(stderr, "### call=9 errno=%u\n", (intptr_t)(int)res == -1 ? errno : 0); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); 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(0x20ffc000, 0x1000); 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; } :321: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :326:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor3627244780 -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/14 (0.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1 + procid*16, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9 + procid*4, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :319: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :323:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor1904720766 -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.35s) csource_test.go:133: opts: {Threaded:true Repeat:true RepeatTimes:0 Procs:4 Slowdown:1 Sandbox:none SandboxArg:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false Wifi:false IEEE802154:false Sysctl:false UseTmpDir:true HandleSegv:false Repro:false Trace:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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) { 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1 + procid*16, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9 + procid*4, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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 < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; } :317: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :321:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2899952042 -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/1 (0.35s) 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:false LegacyOptions:{Collide:false Fault:false FaultCall:0 FaultNth:0}} program: zx_channel_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :315: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :319:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2602453245 -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.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :315: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :319:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2752419580 -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/2 (0.35s) csource_test.go:131: --- FAIL: TestGenerate/fuchsia/amd64/0 (0.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_one(void) { intptr_t res = 0; *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); syz_future_time(1); syz_job_default(); syz_mmap(0x20ffc000, 0x1000); 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; } :178: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :182:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor2977668751 -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/3 (0.35s) csource_test.go:131: --- FAIL: TestGenerate/fuchsia/amd64/9 (0.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :315: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :319:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor4003927188 -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.35s) csource_test.go:131: --- FAIL: TestGenerate/fuchsia/amd64/4 (0.35s) 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_call$fuchsia_process_LauncherCreateWithoutStarting(0x0, 0x0, 0x7fffffffffffffff, &(0x7f00000100c0)={&(0x7f0000000000)={{}, {0x0, 0xffffffff, {0x74}}, {{'*@]:'}}}, &(0x7f0000000040), &(0x7f0000000080), &(0x7f0000010080)={{0x0, 0x0, 0x0, 0x0}}, 0x30, 0x2, 0x10000, 0x4}, &(0x7f0000010100), &(0x7f0000010140)) (fail_nth: 1) zx_channel_read_etc(r1, 0x5, &(0x7f0000010180)=""/108, &(0x7f0000010200)=[{0x0}, {0x0}, {}, {}], 0x6c, 0x4, &(0x7f0000010240), &(0x7f0000010280)) (async) zx_channel_call_etc(r2, 0xedc, 0x7fffffffffffffff, &(0x7f00000104c0)={&(0x7f00000102c0)="1c92be7d4e68435e8f31091a1b8d9a6a219ed95e281c99df2313143e18cccbf2b25a7cebe5101ae99bee17d3a3294d49b3eeaee0d19b2bd783c259081fcd309cbb9dd1c59a6743b6946b11238157ac0a1985cb54ee2c0cd6d236b0d2f6a4cdfb0cca97ba2f0eff3efbf008a97c98daece08ad140b40caa4251ddd5bb5b9c7cf7f152ab834dc3da78619fe55e5336a29b5a2e83", &(0x7f0000010380)=[0x0, r0, r2], &(0x7f00000103c0)=""/154, &(0x7f0000010480)=[0x0, 0x0, 0x0, 0x0, 0x0], 0x93, 0x3, 0x9a, 0x5}, &(0x7f0000010500), &(0x7f0000010540)) (rerun: 4) zx_pager_create_vmo(r5, 0x0, r1, 0x9, 0x3, &(0x7f0000010580)) zx_object_wait_async(r4, r6, 0x1, 0x8001, 0x0) zx_interrupt_trigger(r3, 0x0, 0x7fffffffffffffff) zx_channel_call$fuchsia_cobalt_ControllerBlockUntilEmpty(0x0, 0x0, 0x0, &(0x7f0000020680)={&(0x7f00000105c0)={{}, 0x2}, &(0x7f0000010600), &(0x7f0000010640), &(0x7f0000020640), 0x14, 0x0, 0x10000}, &(0x7f00000206c0), &(0x7f0000020700)) zx_eventpair_create$VALID_OPTIONS(0x0, &(0x7f0000020740), &(0x7f0000020780)=0x0) zx_channel_call$fuchsia_cobalt_LoggerLogFrameRate(r7, 0x0, 0x7fffffffffffffff, &(0x7f0000030880)={&(0x7f00000207c0)={{}, 0x3, 0x353, {0xad2, 0xffffffffffffffff}, 0x5, {'\x9c-[('}}, &(0x7f0000020800), &(0x7f0000020840), &(0x7f0000030840), 0x34, 0x0, 0x10000}, &(0x7f00000308c0), &(0x7f0000030900)) zx_channel_write$fuchsia_io_DirectoryAdminClone(0x0, 0x0, &(0x7f0000040ac0)={{}, 0x40, 0xffffffff}, 0x18, &(0x7f0000040c40), 0x4) syz_execute_func(&(0x7f0000000000)="c461eb2afec482518c13c4214115c446defd26f20f7c4f008fe9f09029c4034d5f5885446643dbc5c4228996b69c370000c4815de5b300f0ffff") syz_future_time(0x1) syz_job_default() syz_mmap(&(0x7f0000ffc000/0x1000)=nil, 0x1000) 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[8] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: *(uint64_t*)0x200100c0 = 0x20000000; *(uint32_t*)0x20000000 = 0; memset((void*)0x20000004, 0, 3); *(uint8_t*)0x20000007 = 1; *(uint64_t*)0x20000008 = 0x4fcfbc1100000000; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = -1; *(uint64_t*)0x20000018 = 0x74; *(uint64_t*)0x20000020 = 0; memcpy((void*)0x20000028, "*@]:", 4); *(uint64_t*)0x200100c8 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint64_t*)0x200100d0 = 0x20000080; *(uint64_t*)0x200100d8 = 0x20010080; *(uint32_t*)0x200100e0 = 0x30; *(uint32_t*)0x200100e4 = 2; *(uint32_t*)0x200100e8 = 0x10000; *(uint32_t*)0x200100ec = 4; inject_fault(1); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0x7fffffffffffffff, 0x200100c0, 0x20010100, 0x20010140); if (res == ZX_OK) { r[0] = *(uint32_t*)0x20010088; r[1] = *(uint32_t*)0x2001008c; } break; case 1: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_read_etc))(r[1], 5, 0x20010180, 0x20010200, 0x6c, 4, 0x20010240, 0x20010280); if (res == ZX_OK) { r[2] = *(uint32_t*)0x20010200; r[3] = *(uint32_t*)0x20010210; } break; case 2: *(uint64_t*)0x200104c0 = 0x200102c0; memcpy((void*)0x200102c0, "\x1c\x92\xbe\x7d\x4e\x68\x43\x5e\x8f\x31\x09\x1a\x1b\x8d\x9a\x6a\x21\x9e\xd9\x5e\x28\x1c\x99\xdf\x23\x13\x14\x3e\x18\xcc\xcb\xf2\xb2\x5a\x7c\xeb\xe5\x10\x1a\xe9\x9b\xee\x17\xd3\xa3\x29\x4d\x49\xb3\xee\xae\xe0\xd1\x9b\x2b\xd7\x83\xc2\x59\x08\x1f\xcd\x30\x9c\xbb\x9d\xd1\xc5\x9a\x67\x43\xb6\x94\x6b\x11\x23\x81\x57\xac\x0a\x19\x85\xcb\x54\xee\x2c\x0c\xd6\xd2\x36\xb0\xd2\xf6\xa4\xcd\xfb\x0c\xca\x97\xba\x2f\x0e\xff\x3e\xfb\xf0\x08\xa9\x7c\x98\xda\xec\xe0\x8a\xd1\x40\xb4\x0c\xaa\x42\x51\xdd\xd5\xbb\x5b\x9c\x7c\xf7\xf1\x52\xab\x83\x4d\xc3\xda\x78\x61\x9f\xe5\x5e\x53\x36\xa2\x9b\x5a\x2e\x83", 147); *(uint64_t*)0x200104c8 = 0x20010380; *(uint32_t*)0x20010380 = 0; *(uint32_t*)0x20010384 = r[0]; *(uint32_t*)0x20010388 = r[2]; *(uint64_t*)0x200104d0 = 0x200103c0; *(uint64_t*)0x200104d8 = 0x20010480; *(uint32_t*)0x200104e0 = 0x93; *(uint32_t*)0x200104e4 = 3; *(uint32_t*)0x200104e8 = 0x9a; *(uint32_t*)0x200104ec = 5; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); { 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_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); } } if (res == ZX_OK) { r[4] = *(uint32_t*)0x20010480; r[5] = *(uint32_t*)0x20010488; r[6] = *(uint32_t*)0x20010490; } break; case 3: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_pager_create_vmo))(r[5], 0, r[1], 0x3f1, 3, 0x20010580); break; case 4: ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_object_wait_async))(r[4], r[6], 0x3e9, 0x8001, 0); break; case 5: ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_interrupt_trigger))(r[3], 0, 0x7fffffffffffffff); break; case 6: *(uint64_t*)0x20020680 = 0x200105c0; *(uint32_t*)0x200105c0 = 0; memset((void*)0x200105c4, 0, 3); *(uint8_t*)0x200105c7 = 1; *(uint64_t*)0x200105c8 = 0x2bf57e3200000000; *(uint32_t*)0x200105d0 = 2; *(uint64_t*)0x20020688 = 0x20010600; *(uint64_t*)0x20020690 = 0x20010640; *(uint64_t*)0x20020698 = 0x20020640; *(uint32_t*)0x200206a0 = 0x14; *(uint32_t*)0x200206a4 = 0; *(uint32_t*)0x200206a8 = 0x10000; *(uint32_t*)0x200206ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(0, 0, 0, 0x20020680, 0x200206c0, 0x20020700); break; case 7: res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(zx_eventpair_create))(0, 0x20020740, 0x20020780); if (res == ZX_OK) r[7] = *(uint32_t*)0x20020780; break; case 8: *(uint64_t*)0x20030880 = 0x200207c0; *(uint32_t*)0x200207c0 = 0; memset((void*)0x200207c4, 0, 3); *(uint8_t*)0x200207c7 = 1; *(uint64_t*)0x200207c8 = 0x2b8722b800000000; *(uint32_t*)0x200207d0 = 3; *(uint32_t*)0x200207d4 = 0x353; *(uint64_t*)0x200207d8 = 0xad2; *(uint64_t*)0x200207e0 = -1; *(uint32_t*)0x200207e8 = 5; memcpy((void*)0x200207ec, "\234-[(", 4); *(uint64_t*)0x20030888 = 0x20020800; *(uint64_t*)0x20030890 = 0x20020840; *(uint64_t*)0x20030898 = 0x20030840; *(uint32_t*)0x200308a0 = 0x34; *(uint32_t*)0x200308a4 = 0; *(uint32_t*)0x200308a8 = 0x10000; *(uint32_t*)0x200308ac = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call))(r[7], 0, 0x7fffffffffffffff, 0x20030880, 0x200308c0, 0x20030900); break; case 9: *(uint32_t*)0x20040ac0 = 0; memset((void*)0x20040ac4, 0, 3); *(uint8_t*)0x20040ac7 = 1; *(uint64_t*)0x20040ac8 = 0x17fe6a4c00000000; *(uint32_t*)0x20040ad0 = 0x40; *(uint32_t*)0x20040ad4 = -1; *(uint32_t*)0x20040c40 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_write))(0, 0, 0x20040ac0, 0x18, 0x20040c40, 4); break; case 10: memcpy((void*)0x20000000, "\xc4\x61\xeb\x2a\xfe\xc4\x82\x51\x8c\x13\xc4\x21\x41\x15\xc4\x46\xde\xfd\x26\xf2\x0f\x7c\x4f\x00\x8f\xe9\xf0\x90\x29\xc4\x03\x4d\x5f\x58\x85\x44\x66\x43\xdb\xc5\xc4\x22\x89\x96\xb6\x9c\x37\x00\x00\xc4\x81\x5d\xe5\xb3\x00\xf0\xff\xff", 58); syz_execute_func(0x20000000); break; case 11: syz_future_time(1); break; case 12: syz_job_default(); break; case 13: syz_mmap(0x20ffc000, 0x1000); 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; } :315: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))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ :319:75: error: use of undeclared identifier 'zx_channel_call_etc' ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(zx_channel_call_etc))(r[2], 0xedc, 0x7fffffffffffffff, 0x200104c0, 0x20010500, 0x20010540); ^ 2 errors generated. compiler invocation: /syzkaller/shared/fuchsia/prebuilt/third_party/clang/linux-x64/bin/clang [-o /tmp/syz-executor1340138496 -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.35s) csource_test.go:131: FAIL FAIL github.com/google/syzkaller/pkg/csource 46.745s ok github.com/google/syzkaller/pkg/db (cached) ok github.com/google/syzkaller/pkg/email (cached) ok github.com/google/syzkaller/pkg/email/lore (cached) ok github.com/google/syzkaller/pkg/host 23.460s ok github.com/google/syzkaller/pkg/ifuzz (cached) ok github.com/google/syzkaller/pkg/image 2.694s ok github.com/google/syzkaller/pkg/instance 6.629s ok github.com/google/syzkaller/pkg/ipc 51.516s ok github.com/google/syzkaller/pkg/kconfig 1.282s ok github.com/google/syzkaller/pkg/kd (cached) ok github.com/google/syzkaller/pkg/log (cached) ok github.com/google/syzkaller/pkg/mgrconfig 4.275s ok github.com/google/syzkaller/pkg/osutil (cached) ok github.com/google/syzkaller/pkg/report 28.713s ok github.com/google/syzkaller/pkg/repro 3.839s ok github.com/google/syzkaller/pkg/runtest 72.551s 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 (cached) ok github.com/google/syzkaller/pkg/subsystem/lists (cached) ok github.com/google/syzkaller/pkg/symbolizer 0.086s ok github.com/google/syzkaller/pkg/tool (cached) ok github.com/google/syzkaller/pkg/vcs (cached) ok github.com/google/syzkaller/prog 12.757s ok github.com/google/syzkaller/prog/test 0.594s ok github.com/google/syzkaller/sys/linux 0.291s ok github.com/google/syzkaller/sys/netbsd 0.076s ok github.com/google/syzkaller/sys/openbsd 0.119s ok github.com/google/syzkaller/syz-ci 5.306s ok github.com/google/syzkaller/syz-fuzzer 0.307s ok github.com/google/syzkaller/syz-hub 0.026s ok github.com/google/syzkaller/syz-hub/state 6.223s ok github.com/google/syzkaller/syz-manager 7.040s ok github.com/google/syzkaller/syz-verifier 5.637s 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.010s ok github.com/google/syzkaller/tools/syz-trace2syz/proggen 0.190s ok github.com/google/syzkaller/vm 13.632s ok github.com/google/syzkaller/vm/isolated 3.668s ok github.com/google/syzkaller/vm/proxyapp 6.489s ok github.com/google/syzkaller/vm/vmimpl 3.815s FAIL