// https://syzkaller.appspot.com/bug?id=ea851fc4688cbac29a567cb49a4fd24d9afff426 // 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_compat_50_mknod #define SYS_compat_50_mknod 14 #endif #ifndef SYS_mmap #define SYS_mmap 197 #endif #ifndef SYS_open #define SYS_open 5 #endif #ifndef SYS_pwritev #define SYS_pwritev 290 #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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000040, "./file0\000", 8); syscall(SYS_compat_50_mknod, 0x20000040ul, 0x2000ul, 0xf000); memcpy((void*)0x200001c0, "./file0\000", 8); res = syscall(SYS_open, 0x200001c0ul, 0x70eul, 0ul); if (res != -1) r[0] = res; *(uint64_t*)0x20000140 = 0; *(uint64_t*)0x20000148 = 0; *(uint64_t*)0x20000150 = 0; *(uint64_t*)0x20000158 = 0; *(uint64_t*)0x20000160 = 0x20000340; memcpy((void*)0x20000340, "\xcb\xfa\x31\xf8\xf7\x8e\xd7\x5c\x15\x00\x22\x77\x55\xb6\x8a\x0a\x66" "\x32\x3a\x1c\x66\x30\x93\x8b\x2f\xdf\x8d\x81\xfe\x70\x2f\xdd\xe5\xec" "\x81\xd0\x9d\x1b\x23\x88\xb1\x53\x15\x6b\xb7\xf1\x3d\x3a\xdf\xdd\xb0" "\x3b\xff\x84\x81\x4e\x93\xe0\x74\xe3\x94\xab\x31\xb7\x04\x96\x8e\x21" "\xcd\x60\x6b\x86\x8e\x80\xde\x83\x70\x71\x5e\xc5\xc3\x4f\xa3\xa2\x4a" "\x6e\x22\x8b\x0f\xb5\xc1\xf8\xd8\x4d\xf6\xae\x16\x16\x38\x88\x33\x56" "\x07\x64\xcd\x7a\xe1\x1e\x42\x8a\x3e\x41\xe8\x2e\x13\x76\xe2\x8e\x60" "\x0b\xad\x30\x58\xce\xbe\xb4\xce\x85\x07\xa0\xca\xcb\xe5\xe6\x08\x83" "\x36\x47\xd0\x16\xd6\xf1\xac\x6a\xd1\x3a\x9f\x02\x5a\x51\xc6\x27\x4e" "\x30\x38\x35\x55\x7a\xd7\xbe\x14\x07\x9c\xc1\x91", 165); *(uint64_t*)0x20000168 = 0xa5; syscall(SYS_pwritev, r[0], 0x20000140ul, 3ul, -1ul); } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }