// https://syzkaller.appspot.com/bug?id=4e947674d10b0fb0cb94d4d723989cee439a71d6 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms() { 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 SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); } #define SYZ_HAVE_RESET_TEST 1 static void reset_test() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } static void execute_one(); #define WAIT_FLAGS __WALL static void loop() { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); reset_test(); 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(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, WAIT_FLAGS) != pid) { } break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one() { long res = 0; res = syscall(__NR_socket, 2, 0x200000002, 0x88); if (res != -1) r[0] = res; *(uint16_t*)0x20000000 = 2; *(uint16_t*)0x20000002 = htobe16(0x4e21); *(uint32_t*)0x20000004 = htobe32(0); *(uint8_t*)0x20000008 = 0; *(uint8_t*)0x20000009 = 0; *(uint8_t*)0x2000000a = 0; *(uint8_t*)0x2000000b = 0; *(uint8_t*)0x2000000c = 0; *(uint8_t*)0x2000000d = 0; *(uint8_t*)0x2000000e = 0; *(uint8_t*)0x2000000f = 0; syscall(__NR_bind, r[0], 0x20000000, 0x10); res = syscall(__NR_dup2, r[0], r[0]); if (res != -1) r[1] = res; *(uint16_t*)0x20000100 = 2; *(uint16_t*)0x20000102 = htobe16(0x4e21); *(uint32_t*)0x20000104 = htobe32(0); *(uint8_t*)0x20000108 = 0; *(uint8_t*)0x20000109 = 0; *(uint8_t*)0x2000010a = 0; *(uint8_t*)0x2000010b = 0; *(uint8_t*)0x2000010c = 0; *(uint8_t*)0x2000010d = 0; *(uint8_t*)0x2000010e = 0; *(uint8_t*)0x2000010f = 0; syscall(__NR_sendto, r[1], 0x20000140, 0, 0x8000, 0x20000100, 0x10); *(uint16_t*)0x20000040 = 2; *(uint16_t*)0x20000042 = htobe16(0); *(uint8_t*)0x20000044 = 0xac; *(uint8_t*)0x20000045 = 0x14; *(uint8_t*)0x20000046 = 0x14; *(uint8_t*)0x20000047 = 0xbb; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint8_t*)0x2000004c = 0; *(uint8_t*)0x2000004d = 0; *(uint8_t*)0x2000004e = 0; *(uint8_t*)0x2000004f = 0; syscall(__NR_sendto, r[0], 0x20000180, 0x2f6, 0, 0x20000040, 0x10); res = syscall(__NR_socket, 0x10, 3, 6); if (res != -1) r[2] = res; *(uint64_t*)0x200016c0 = 0x20000040; *(uint16_t*)0x20000040 = 0x10; *(uint16_t*)0x20000042 = 0; *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x200016c8 = 0xc; *(uint64_t*)0x200016d0 = 0x20001680; *(uint64_t*)0x20001680 = 0x20000300; *(uint32_t*)0x20000300 = 0xb8; *(uint16_t*)0x20000304 = 0x19; *(uint16_t*)0x20000306 = 0xa07; *(uint32_t*)0x20000308 = 0; *(uint32_t*)0x2000030c = 0; *(uint32_t*)0x20000310 = htobe32(-1); *(uint32_t*)0x20000320 = htobe32(0x7f000001); *(uint16_t*)0x20000330 = htobe16(0); *(uint16_t*)0x20000332 = htobe16(0); *(uint16_t*)0x20000334 = htobe16(0); *(uint16_t*)0x20000336 = htobe16(0); *(uint16_t*)0x20000338 = 2; *(uint8_t*)0x2000033a = 0; *(uint8_t*)0x2000033b = 0; *(uint8_t*)0x2000033c = 0; *(uint32_t*)0x20000340 = 0; *(uint32_t*)0x20000344 = 0; *(uint64_t*)0x20000348 = 0; *(uint64_t*)0x20000350 = 0; *(uint64_t*)0x20000358 = 0; *(uint64_t*)0x20000360 = 0; *(uint64_t*)0x20000368 = 0; *(uint64_t*)0x20000370 = 0; *(uint64_t*)0x20000378 = 0; *(uint64_t*)0x20000380 = 0; *(uint64_t*)0x20000388 = 0; *(uint64_t*)0x20000390 = 0; *(uint64_t*)0x20000398 = 0; *(uint64_t*)0x200003a0 = 0; *(uint32_t*)0x200003a8 = 0; *(uint32_t*)0x200003ac = 0; *(uint8_t*)0x200003b0 = 0; *(uint8_t*)0x200003b1 = 0; *(uint8_t*)0x200003b2 = 0; *(uint8_t*)0x200003b3 = 0; *(uint64_t*)0x20001688 = 0xb8; *(uint64_t*)0x200016d8 = 1; *(uint64_t*)0x200016e0 = 0; *(uint64_t*)0x200016e8 = 0; *(uint32_t*)0x200016f0 = 0; syscall(__NR_sendmsg, r[2], 0x200016c0, 0); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }