// 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; 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*)0x20001200, "/net/tcp/2/local\000", 17); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20001200ul, 0x11ul, 1ul, 0ul); if (res != -1) r[0] = res; syscall(SYS_close, r[0]); memcpy((void*)0x200012c0, "/prof/.empty\000", 13); syscall(SYS_openat, 0xffffffffffffff9cul, 0x200012c0ul, 0xdul, 3ul, 0ul); memcpy((void*)0x20000000, "\xe9\xaa\x4c\x97\x84\x12\x0e\x10\xbd\x24\xef\x3d\x0b\xcc\x39\x7b\xe4" "\x58\x01\x11\xdd\x1b\x58\x97\xea\xa7\x98\x99\x3c\xed\x69\x50\x77\xd5" "\x38\x4e\x65\x2a\xfb\x34\x18\x5a\xe0\xc5\xbc\x93\x9a\x1d\x05\x00\x00" "\x00\x3a\xe1\xe1\x24\x89\x0b\x76\x57\x4c\x0c\x48\x22\x52\x3b\x26\xaf" "\xaf\x0f\xf1\x16\x08\x95\x21\xa6\xd1\xb9\xd8\x09\x0e\x65\x7e\x84\x5f" "\x3b\x54\x96\x99\xc3\x8d\xdf\x4e\x1d\x65\x82\xbc\x6f\x3a\x76\x8f\x5b" "\x0b\x02\x3c\x06\xe7\x0d\x8a\x6b\x9d\x89\xfb\x12\x8d\x0c\x96\x87\x27" "\x3c\xda\x09\xe0\xad\xa4\xad\x58\xa6\x35\x89\x54\x0c\xc4\x9f\x84\xa2" "\xf3\xc3\x4d\xb6\xb6\x9e\x68\x40\xab\x94\xf8\xbc\xf1\xf2\x9a\x80\xe9" "\x88\x7a\xbd\x35\x32\x44\x3d\xda\x03\xbf\x2b\x0f\x61\xf1\xa3\x3a\xf0" "\xf4\x6d\x1a\xff\x03\xe8\x79\x39\x96\x2f\xf1\x18\x73\x7a\x4a\xa3\x46" "\x11\x24\x72\x92\x69\x8c\x18\x65\xc7\x3a\x80\xc5\x79\xeb\xe0\xe3\x7e" "\xfe\x00", 206); syscall(SYS_write, r[0], 0x20000000ul, 0x80000001ul); } 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; }