// 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 = 0; for (;; 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*)0x20000340, "/net/tcp/1/status\000", 18); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000340ul, 0x12ul, 1ul, 0ul); if (res != -1) r[0] = res; syscall(SYS_close, r[0]); memcpy((void*)0x20000080, "/prof/.empty\000", 13); syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000080ul, 0xdul, 3ul, 0ul); memcpy((void*)0x20000140, "\xc3\x5a\xf8\xa2\xde\x28\xdf\xd2\x5d\x01\xdc\xbe\x22\xb7\x20\x08\x30" "\xe8\x28\xae\xf8\x46\x31\xa2\x14\xee\xf6\x47\xa0\xf1\x09\xd6\x01\xe4" "\x09\xa9\x3d\x45\xba\x04\x33\x7e\x20\xa4\x4b\xae\x41\x5b\xec\xb3\xa5" "\xb4\xcd\x79\x69\xc8\xcd\xa3\x4d\x93\x5b\x8b\x5a\x01\x96\x71\x55\x3f" "\x5b\x3a\xab\x8a\x57\xcd\xbd\xe4\x2f\x98\xb8\x00\x74\xb4\x4b\xb4\x30" "\xed\x35\xf1\x66\xee\x0e\xd3\xff\x08\x00\x00\x00\xec\xf4\x79\x85\xf3" "\xdb\x84\x07\x60\xf3\x81\x0a\x67\xab\x4f\x21\xa5\x0d\x79\x0f\xa6\x73" "\x34\x8c\x19\xec\x84\xc1\x9c\x31\xe7\x52\x70\x03\x91\x95\xd6\x7e\xf5" "\xe1\xe2\x6d\xd6\x83\xab\x3a\x61\xea\xb7\x98\x75\xeb\x32\xba\x5c\xd4" "\x60\xde\x14\x8b\xa8\x2c\xa2\x6a\xe3\xb0\xf1\xa8\x79\xf3\x59\x4d\x27" "\x1b\x01\xb4\x0d\x4f\x69\x17\xb2\x6c\x66\x20\xa4\xc4\xd0\x48", 185); syscall(SYS_write, r[0], 0x20000140ul, 0xfffffe7dul); } 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; }