// https://syzkaller.appspot.com/bug?id=d099adf22293cc35802421775065018c17b56272 // 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 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; } #define __syscall syscall 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; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x200000c0, ".\000", 2); res = syscall(SYS_open, 0x200000c0ul, 0ul, 0ul); if (res != -1) r[0] = res; res = syscall(SYS_socketpair, 1ul, 1ul, 0, 0x20000040ul); if (res != -1) { r[1] = *(uint32_t*)0x20000040; r[2] = *(uint32_t*)0x20000044; } *(uint64_t*)0x200000c0 = 0; *(uint32_t*)0x200000c8 = 0; *(uint64_t*)0x200000d0 = 0; *(uint64_t*)0x200000d8 = 0; *(uint64_t*)0x200000e0 = 0x20000100; memcpy((void*)0x20000100, "\x28\x00\x00\x00\xff\xff\x00\x00\x01\x00\x00\x00\x08\xae\x7f\xdf\x03" "\x00\x00\x00", 20); *(uint32_t*)0x20000114 = r[2]; *(uint32_t*)0x20000118 = r[2]; *(uint32_t*)0x2000011c = r[0]; *(uint32_t*)0x20000120 = r[1]; *(uint32_t*)0x20000124 = r[2]; *(uint64_t*)0x200000e8 = 0x28; *(uint32_t*)0x200000f0 = 0; syscall(SYS_sendmsg, r[2], 0x200000c0ul, 0ul); } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); loop(); return 0; }