// https://syzkaller.appspot.com/bug?id=a12a0d53e98be4a617f1e02e8ae91dc4a31525f8 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #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; } static void execute_one(); const char* program_name; void child() { execute_one(); exit(0); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execl(program_name, program_name, "child", NULL); exit(1); } 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 < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000340, "/dev/ppid\000", 10); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000340ul, 0xaul, 1ul, 0ul); if (res != -1) r[0] = res; syscall(SYS_close, r[0]); memcpy((void*)0x20000400, "/prof/.empty\000", 13); syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000400ul, 0xdul, 3ul, 0ul); syscall(SYS_write, r[0], 0x20000000ul, 0xfffffe40ul); } int main(int argc, char** argv) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); program_name = argv[0]; if (argc == 2 && strcmp(argv[1], "child") == 0) child(); loop(); return 0; }