// https://syzkaller.appspot.com/bug?id=906433df4abcde9bf8261b1c105f7a48418b8663 // 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 #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } 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; } #define CAST static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000040, "./file0\000", 8); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000040, /*flags=O_CREAT*/0x200, /*mode=*/0); memcpy((void*)0x20000000, "./file0\000", 8); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(open))(/*file=*/0x20000000, /*flags=O_RDWR*/2, /*mode=*/0); if (res != -1) r[0] = res; *(uint64_t*)0x20000340 = 0x20000000; *(uint64_t*)0x20000348 = 0x2cfea; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(writev))(/*fd=*/r[0], /*vec=*/0x20000340, /*vlen=*/0x1000000000000013); memcpy((void*)0x20000640, "/dev/rvnd0c\000", 12); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000640, /*flags=*/0, /*mode=*/0); if (res != -1) r[1] = res; ((intptr_t(*)())CAST(kqueue))(); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t))CAST(dup2))(/*oldfd=*/r[1], /*newfd=*/r[1]); if (res != -1) r[2] = res; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0, /*flags=*/0, /*mode=*/0); *(uint64_t*)0x20000140 = 0x200000c0; memcpy((void*)0x200000c0, "./file0\000", 8); *(uint64_t*)0x20000148 = 0x30e2d8f8; *(uint64_t*)0x20000150 = 0x20000100; memcpy((void*)0x20000100, "./file0\000", 8); *(uint32_t*)0x20000158 = 8; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[2], /*cmd=*/0xc0384600, /*arg=*/0x20000140); } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x20000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); loop(); return 0; }