// 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); memcpy((void*)0x20000040, "\x60\xb6\x79\x28\x32\xda\xe6\xa5\xd2\xfd\x1e\x62\x65\x99\xbf\x8e\xb2" "\x63\x27\x7d\xd5\x01\xa1\x05\x91\x5c\x58\x05\xa7\x03\xf1\x00\x7c\xe5" "\x80\x30\x95\xf4\x6b\xfe\x2a\x04\x36\xaa\xd7\x81\x80\x84\x44\x4b\x0f" "\x32\x10\x7c\x20\x24\xef\x15\x2f\x70\x01\x00\x00\x00\xe0\x78\xce\x0c" "\x60\xea\x90\x13\x10\x0e\xfc\x44\x9e\xdf", 78); syscall(SYS_write, r[0], 0x20000040ul, 0xfffffef8ul); } int main(int argc, char** argv) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x32ul, -1, 0ul); program_name = argv[0]; if (argc == 2 && strcmp(argv[1], "child") == 0) child(); loop(); return 0; }