// https://syzkaller.appspot.com/bug?id=efb172979756a82d2d1429c667c30a0a10b492d4 // 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 = 0; for (;; 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*)0x20000000, "/prof/.empty\000", 13); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000000ul, 0xdul, 3ul, 0ul); if (res != -1) r[0] = res; memcpy((void*)0x20000140, "\x68\x0d\x0f\x37\x2d\xd7\xbd\xd5\x73\xe5\x01\xca\x83\xde\x92\x9e\xd7" "\x92\xdf\xa4\x4b\x10\x27\x20\x08\xda\xc8\x83\x0f\xcd\xd7\x35\x05\xec" "\x09\x0b\x40\xc9\xad\x02\x0b\x9a\x45\xf8\x61\x13\x76\x4c\x15\x7c\x1f" "\x7e\x48\x78\x10\xd0\xfd\x46\xdb\xc3\x33\x20\xeb\xf9\xcd\x63\x1c\xa8" "\xee\x0a\x81\x18\xe7\xbd\x7d\x57\x0a\xbf\xef\xc5\x6b\x91\xb1\x08\x24" "\x93\x05\x34\x04\x7b\x92\xc3\xc4", 93); syscall(SYS_write, r[0], 0x20000140ul, 0xfffffefcul); } 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; }