// https://syzkaller.appspot.com/bug?id=90a4811c99d6a2df7b252971b754612ca632894d // 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 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; } #define __syscall syscall 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) { 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 < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[5] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000040, "./file0\000", 8); res = syscall(SYS_open, 0x20000040ul, 0x60eul, 0ul); if (res != -1) r[0] = res; *(uint64_t*)0x20000080 = 0x20000180; memcpy((void*)0x20000180, "\xfd\xff\xff\xff\xff\xff\xff\xff", 8); *(uint64_t*)0x20000088 = 8; syscall(SYS_pwritev, r[0], 0x20000080ul, 1ul, 0ul); *(uint64_t*)0x20000140 = 0x200000c0; memcpy((void*)0x200000c0, "\x44\x02", 2); *(uint64_t*)0x20000148 = 2; syscall(SYS_pwritev, r[0], 0x20000140ul, 1ul, 0ul); syscall(SYS_mmap, 0x20000000ul, 0x13000ul, 5ul, 0x10ul, r[0], 0ul); res = syscall(SYS_socket, 2ul, 3ul, 0); if (res != -1) r[1] = res; res = syscall(SYS_socket, 2ul, 2ul, 0); if (res != -1) r[2] = res; syscall(SYS_dup2, r[1], r[2]); syscall(SYS_connect, r[2], 0x20000000ul, 0x10ul); res = syscall(SYS_socket, 2ul, 0x4003ul, 0); if (res != -1) r[3] = res; syscall(SYS_setsockopt, -1, 0, 0x14, 0ul, 0ul); syscall(SYS_connect, r[3], 0ul, 0x10ul); syscall(SYS_write, r[1], 0ul, 0ul); res = syscall(SYS_openat, 0xffffffffffffff9cul, 0ul, 0x4000000001ul, 0ul); if (res != -1) r[4] = res; syscall(SYS_ioctl, r[4], 0x8020426cul, 0ul); syscall(SYS_setsockopt, -1, 0, 0x14, 0x20000080ul, 0ul); memcpy((void*)0x200000c0, "tap", 3); *(uint8_t*)0x200000c3 = 0x30 + procid * 1; *(uint8_t*)0x200000c4 = 0; syscall(SYS_ioctl, r[4], 0x8020426cul, 0x200000c0ul); syscall(SYS_setsockopt, -1, 0, 0x14, 0ul, 0ul); syscall(SYS_dup2, -1, -1); } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul); for (procid = 0; procid < 8; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }