// 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*)0x200003c0, "/net/tcp/0/err\000", 15); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x200003c0ul, 0xful, 3ul, 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*)0x20000080, "\xcf\x2d\xb0\x20\x8b\x86\x98\x0e\x23\x02\x1a\x6a\x72\x6a\xb9\xc8\x27" "\x58\xac\x70\xc2\x22\xed\x35\x8a\x30\xb0\x8f\x70\x7f\x30\xdd\x75\x39" "\x70\x88\x87\x7f\x95\x86\x45\x6e\xfb\x35\xa0\xcd\x21\x3b\x1e\xab\x70" "\x78\x93\x01\x1d\x57\x42\xb6\xea\xb7\x6f\xb9\xd8\x16\x81\xc0\xb5\xd2" "\x7b\x05\x53\x68\xa9\x67\x65\x7f\xa8\x55\xed\x80\xf7\xb6\x28\x45\xa9" "\xa1\x3c\x5e\x7e\xf3\xb7\x64\xa8\x65\x9c\xf8\x63\x14\x77\xe4\x56\x39" "\x4e\xce\x7e\xac\xe0\x56", 108); syscall(SYS_write, r[0], 0x20000080ul, 0xfffffda9ul); } 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; }