// https://syzkaller.appspot.com/bug?id=479d6cbadd1e0f9effe7ffaaf3ce63cc14459988 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include const int kFailStatus = 67; const int kRetryStatus = 69; __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } __attribute__((noreturn)) static void fail(const char* msg, ...) { int e = errno; fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); } __attribute__((noreturn)) static void exitf(const char* msg, ...) { int e = errno; fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } static uint64_t current_time_ms() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void test(); void loop() { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) fail("clone failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); test(); doexit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { int res = waitpid(-1, &status, __WALL | WNOHANG); if (res == pid) break; usleep(1000); if (current_time_ms() - start > 5 * 1000) { kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } } } } long r[94]; void* thr(void* arg) { switch ((long)arg) { case 0: r[0] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); break; case 1: r[1] = syscall(__NR_setsockopt, 0xfffffffffffffffful, 0x1ul, 0x0ul, 0x0ul, 0x0ul); break; case 2: *(uint32_t*)0x20001000 = (uint32_t)0x10000; *(uint32_t*)0x20001004 = (uint32_t)0xc000800000000001; *(uint32_t*)0x20001008 = (uint32_t)0x10000; *(uint32_t*)0x2000100c = (uint32_t)0x1; r[6] = syscall(__NR_setsockopt, 0xfffffffffffffffful, 0x84ul, 0x0ul, 0x20001000ul, 0x10ul); break; case 3: r[7] = syscall(__NR_socketpair, 0xaul, 0xbul, 0x80000000ul, 0x2054e000ul); if (r[7] != -1) r[8] = *(uint32_t*)0x2054e004; break; case 4: *(uint32_t*)0x202f4f74 = (uint32_t)0x0; *(uint16_t*)0x202f4f78 = (uint16_t)0xa; *(uint16_t*)0x202f4f7a = (uint16_t)0x204e; *(uint32_t*)0x202f4f7c = (uint32_t)0x6; *(uint8_t*)0x202f4f80 = (uint8_t)0xfe; *(uint8_t*)0x202f4f81 = (uint8_t)0x80; *(uint8_t*)0x202f4f82 = (uint8_t)0x0; *(uint8_t*)0x202f4f83 = (uint8_t)0x0; *(uint8_t*)0x202f4f84 = (uint8_t)0x0; *(uint8_t*)0x202f4f85 = (uint8_t)0x0; *(uint8_t*)0x202f4f86 = (uint8_t)0x0; *(uint8_t*)0x202f4f87 = (uint8_t)0x0; *(uint8_t*)0x202f4f88 = (uint8_t)0x0; *(uint8_t*)0x202f4f89 = (uint8_t)0x0; *(uint8_t*)0x202f4f8a = (uint8_t)0x0; *(uint8_t*)0x202f4f8b = (uint8_t)0x0; *(uint8_t*)0x202f4f8c = (uint8_t)0x0; *(uint8_t*)0x202f4f8d = (uint8_t)0x0; *(uint8_t*)0x202f4f8e = (uint8_t)0x0; *(uint8_t*)0x202f4f8f = (uint8_t)0xaa; *(uint32_t*)0x202f4f90 = (uint32_t)0xfffffffffffffffa; *(uint64_t*)0x202f4f98 = (uint64_t)0x0; *(uint64_t*)0x202f4fa0 = (uint64_t)0x0; *(uint64_t*)0x202f4fa8 = (uint64_t)0x0; *(uint64_t*)0x202f4fb0 = (uint64_t)0x0; *(uint64_t*)0x202f4fb8 = (uint64_t)0x0; *(uint64_t*)0x202f4fc0 = (uint64_t)0x0; *(uint64_t*)0x202f4fc8 = (uint64_t)0x0; *(uint64_t*)0x202f4fd0 = (uint64_t)0x0; *(uint64_t*)0x202f4fd8 = (uint64_t)0x0; *(uint64_t*)0x202f4fe0 = (uint64_t)0x0; *(uint64_t*)0x202f4fe8 = (uint64_t)0x0; *(uint64_t*)0x202f4ff0 = (uint64_t)0x0; *(uint32_t*)0x20082ffc = (uint32_t)0x8c; r[43] = syscall(__NR_getsockopt, 0xfffffffffffffffful, 0x84ul, 0x6ul, 0x202f4f74ul, 0x20082ffcul); if (r[43] != -1) r[44] = *(uint32_t*)0x202f4f74; break; case 5: *(uint32_t*)0x204f2f94 = (uint32_t)0x0; *(uint32_t*)0x204f2f98 = (uint32_t)0x0; *(uint32_t*)0x20632ffc = (uint32_t)0x8; r[48] = syscall(__NR_getsockopt, 0xffffffffffffff9cul, 0x84ul, 0x6dul, 0x204f2f94ul, 0x20632ffcul); if (r[48] != -1) r[49] = *(uint32_t*)0x204f2f94; break; case 6: *(uint32_t*)0x2040bf48 = r[44]; *(uint32_t*)0x2040bf4c = (uint32_t)0x20; *(uint32_t*)0x2040bf50 = (uint32_t)0x3; *(uint16_t*)0x2040bf54 = (uint16_t)0xa1ab; *(uint16_t*)0x2040bf56 = (uint16_t)0x800; *(uint16_t*)0x2040bf58 = (uint16_t)0x101; *(uint16_t*)0x2040bf5a = (uint16_t)0x401; *(uint32_t*)0x2040bf5c = (uint32_t)0x8000; *(uint32_t*)0x2040bf60 = r[49]; *(uint16_t*)0x2040bf64 = (uint16_t)0xa; *(uint16_t*)0x2040bf66 = (uint16_t)0x204e; *(uint32_t*)0x2040bf68 = (uint32_t)0x4; *(uint64_t*)0x2040bf6c = (uint64_t)0x0; *(uint64_t*)0x2040bf74 = (uint64_t)0x100000000000000; *(uint32_t*)0x2040bf7c = (uint32_t)0x6; *(uint64_t*)0x2040bf84 = (uint64_t)0x0; *(uint64_t*)0x2040bf8c = (uint64_t)0x0; *(uint64_t*)0x2040bf94 = (uint64_t)0x0; *(uint64_t*)0x2040bf9c = (uint64_t)0x0; *(uint64_t*)0x2040bfa4 = (uint64_t)0x0; *(uint64_t*)0x2040bfac = (uint64_t)0x0; *(uint64_t*)0x2040bfb4 = (uint64_t)0x0; *(uint64_t*)0x2040bfbc = (uint64_t)0x0; *(uint64_t*)0x2040bfc4 = (uint64_t)0x0; *(uint64_t*)0x2040bfcc = (uint64_t)0x0; *(uint64_t*)0x2040bfd4 = (uint64_t)0x0; *(uint64_t*)0x2040bfdc = (uint64_t)0x0; *(uint32_t*)0x2040bfec = (uint32_t)0x9; *(uint32_t*)0x2040bff0 = (uint32_t)0x1f; *(uint32_t*)0x2040bff4 = (uint32_t)0x9; *(uint32_t*)0x2040bff8 = (uint32_t)0x0; *(uint32_t*)0x2040bffc = (uint32_t)0x7ff; *(uint32_t*)0x20f3e000 = (uint32_t)0xb8; r[83] = syscall(__NR_getsockopt, r[8], 0x84ul, 0xeul, 0x2040bf48ul, 0x20f3e000ul); break; case 7: r[84] = syscall(__NR_socket, 0x11ul, 0x80003ul, 0x8ul); break; case 8: *(uint16_t*)0x20cdeffc = (uint16_t)0x8001; *(uint8_t*)0x20cdeffe = (uint8_t)0x3; *(uint8_t*)0x20cdefff = (uint8_t)0x1000; r[88] = syscall(__NR_setsockopt, r[84], 0x107ul, 0x12ul, 0x20cdeffcul, 0x4ul); break; case 9: *(uint16_t*)0x2052e000 = (uint16_t)0x0; *(uint8_t*)0x2052e002 = (uint8_t)0x0; *(uint8_t*)0x2052e003 = (uint8_t)0x0; r[92] = syscall(__NR_setsockopt, r[84], 0x107ul, 0x12ul, 0x2052e000ul, 0x4ul); break; case 10: r[93] = syscall(__NR_setsockopt, r[84], 0x107ul, 0x5ul, 0x20001000ul, 0x47eul); break; } return 0; } void test() { long i; pthread_t th[22]; memset(r, -1, sizeof(r)); srand(getpid()); for (i = 0; i < 11; i++) { pthread_create(&th[i], 0, thr, (void*)i); usleep(rand() % 10000); } for (i = 0; i < 11; i++) { pthread_create(&th[11 + i], 0, thr, (void*)i); if (rand() % 2) usleep(rand() % 10000); } usleep(rand() % 100000); } int main() { int i; for (i = 0; i < 8; i++) { if (fork() == 0) { loop(); return 0; } } sleep(1000000); return 0; }