// https://syzkaller.appspot.com/bug?id=3600bb95d29f679b10596a509fe14da871b45b70 // 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 #ifndef SYS_dup2 #define SYS_dup2 90 #endif #ifndef SYS_mknod #define SYS_mknod 450 #endif #ifndef SYS_mmap #define SYS_mmap 197 #endif #ifndef SYS_open #define SYS_open 5 #endif #ifndef SYS_writev #define SYS_writev 121 #endif 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; } 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000000, "./file0\000", 8); syscall(SYS_mknod, /*file=*/0x20000000ul, /*mode=*/0x80002005ul, /*dev=*/0ul); memcpy((void*)0x20000000, "./file0\000", 8); res = syscall(SYS_open, /*file=*/0x20000000ul, /*flags=*/2ul, /*mode=*/0ul); if (res != -1) r[0] = res; memcpy((void*)0x20000000, "./file0\000", 8); res = syscall(SYS_open, /*file=*/0x20000000ul, /*flags=*/0ul, /*mode=*/0ul); if (res != -1) r[1] = res; res = syscall(SYS_dup2, /*oldfd=*/r[0], /*newfd=*/r[1]); if (res != -1) r[2] = res; *(uint64_t*)0x20000200 = -1; *(uint64_t*)0x20000208 = 0x45; *(uint64_t*)0x20000210 = 0x20000240; memcpy((void*)0x20000240, "\x09\xa9\x45\x46\x8a\x23\x5d\xe1\x98\x65\xc2\xe4\x77\xa6\x00\x27\x0d" "\x5c\xe2\x32\xbb\x6d\x62\xdd\x78\xcd\xf8\x46\xe2\x6e\xfb\x50\x22\x7c" "\x7d\x80\x3d\x59\xf6\x56\x09\x4d\x86\x60\x51\xdb\xac\x8f\x92\x66\x53" "\x47\xe1\xd2\x67\x8c\x12\x43\x72\x25\xf0\x41\x59\x74\x3b\x67\xac\xbd" "\x49\x2b\x50\x18\x27\xc0\x2f\x66\x3b\xee\xb9\x13\x42\x3e", 82); *(uint64_t*)0x20000218 = 0x52; *(uint64_t*)0x20000220 = 0x20000140; memcpy((void*)0x20000140, "\x7c\xa1\xe3\x7a\x9b\x2c\x86\xec\xbe\xf9\xb8\x64\x8b\xa0\xb7\xc2\x51" "\xc6\xa2\x02\xce\xdf\x15\x7e\x49\xab\x47\xf2\x3c\x92\xa9\xc5\xc7\xdc" "\xb0\x92\x75\x30\x78\xfd\xb8\x7f\x8d\x21\x70\x32\x27\x7d\x55\xc3\x81" "\x36\x3d\x39\x20\x32\x81\xd4\xa5\x92\x03\x72\x50\xde\x4a\xc2\x93\xbd" "\x3f\x3a\x2e\xd3\x17\xcd\xd9\x46\x87\xd3\x99\x66\xc2\x9e\x62\x7d\x6d" "\xd1\x89\xab\x11\xb0\x29\x78\x37\x5c\xd1\x2b\x32\x1a\xf5\x48\xa9\x1d" "\xf9\x1e\xc7\xf1\x9d\x04\xa1\xe7\xd9\x89\x53\x1e\x14\x1e\xa8\x0e\xf4" "\x04\x6a\xc1\x9b\xe1\xac\xcf\x1b\x17\xe0\xc3\x4d\x5f\x08\xf5\x50\x18" "\x7b\x5b\xe7\xd0\x21\x74\x13\xa4\xc4\xee\x86\xea\x52\x94\xaa\xa1\x03" "\xf2\xb7\x91\x89\x8f\x09\x5d\x93\x2e\x3c", 163); *(uint64_t*)0x20000228 = 0xa3; syscall(SYS_writev, /*fd=*/r[2], /*vec=*/0x20000200ul, /*vlen=*/3ul); } int main(void) { syscall(SYS_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/3ul, /*flags=*/0x1012ul, /*fd=*/-1, /*pad=*/0ul, /*offset=*/0ul); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }