// https://syzkaller.appspot.com/bug?id=a74718ca902617e6aa7327aa008b25844eccf2d3 // 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; res = syscall(SYS_socketpair, 1, 1, 0, 0x20000040); if (res != -1) { r[0] = *(uint32_t*)0x20000040; r[1] = *(uint32_t*)0x20000044; } memcpy((void*)0x20000200, "/dev/bpf\000", 9); res = syscall(SYS_openat, 0xffffffffffffff9c, 0x20000200, 0, 0); if (res != -1) r[2] = res; *(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\xcd\x7f\xdf\x03" "\x00\x00\x00", 20); *(uint32_t*)0x20000114 = r[1]; *(uint32_t*)0x20000118 = r[2]; *(uint32_t*)0x2000011c = 0; *(uint32_t*)0x20000120 = r[0]; *(uint32_t*)0x20000124 = r[1]; *(uint64_t*)0x200000e8 = 0x28; *(uint32_t*)0x200000f0 = 0; syscall(SYS_sendmsg, r[1], 0x200000c0, 0); } int main(void) { syscall(SYS_mmap, 0x20000000, 0x1000000, 3, 0x1012, -1, 0, 0); loop(); return 0; }