// https://syzkaller.appspot.com/bug?id=422cd2682bda7bd00e8b318221985dbad2010757 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include unsigned long long procid; 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(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) { execute_one(); exit(0); } 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; } } } #ifndef SYS_mmap #define SYS_mmap 197 #endif #ifndef SYS_socket #define SYS_socket 394 #endif #ifndef SYS_writev #define SYS_writev 121 #endif uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = syscall(SYS_socket, 0x22, 3, 0); if (res != -1) r[0] = res; *(uint64_t*)0x200014c0 = 0x20000000; memcpy((void*)0x20000000, "\x9f\x88\x5b\x81\x22\x43\xe2\x9e\x69\x3b\x67\xc6\x9d\xe7\xba\xc1\x60" "\xdc\x58\xa6\xa2\x2b\x89\x32\x1c\xe8\x25\x9b\xf6\xf7\x33\xae\x68\x58" "\x44\xf4\xda\x8b\x39\x0e\xf0\x16\xa1\x44\xd1\xad\xca\x12\x2e\x68\x13" "\x68\x4f\x4b\x7e\xbf\xc6\x14\x5e\x09\xbd\xb5\xae\x15\xb8\x05\x89\xf2" "\xc4\x55\xda\x99\x83\x51\x65\xa7\x4a\x74\x89\x82\xde\xf9\xb0\xb2\xe5" "\x50\x88\x9e\x1d\x35\x89\xe2\xbd\x86\x19\xc3\x3e\x39\xcb\xca\x13\x5c" "\xd4\x21\x36\xcf\x73\xb8\x35\x34\xf0\xe9\x32\x44\x5b\x0b\x72\x48\x9a" "\x51\x74\x56\x94\x65\x2d\x52\x6b\x1a\x47\x0b\x83\xb4\x93\x7a\xf1\xe9" "\x06\x98\xa7\x5c\xd2\x15\xf3\x30\xd0\xd0\xea\xd7\xe3\xf6\xa5\xab\xbf" "\xaa\xac\x6c\x6b\xcb", 158); *(uint64_t*)0x200014c8 = 0x9e; *(uint64_t*)0x200014d0 = 0; *(uint64_t*)0x200014d8 = 0; syscall(SYS_writev, r[0], 0x200014c0, 2); } int main(void) { syscall(SYS_mmap, 0x20000000, 0x1000000, 3, 0x1012, -1, 0, 0); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }