// https://syzkaller.appspot.com/bug?id=f9aee1b671ee4c1fbafc98d36a896b996ea9c0bc // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include #include #include #include #include const int kFailStatus = 67; const int kRetryStatus = 69; static void fail(const char* msg, ...) { int e = errno; 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); } 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 execute_one(); extern unsigned long long procid; static 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(); execute_one(); int fd; for (fd = 3; fd < 30; fd++) close(fd); 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) continue; kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } } } uint64_t r[4] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one() { long res = 0; res = syscall(__NR_inotify_init1, 0x80800); if (res != -1) r[0] = res; syscall(__NR_fcntl, r[0], 8, -1); res = syscall(__NR_fcntl, r[0], 0x10, 0x2045fff8); if (res != -1) r[1] = *(uint32_t*)0x2045fffc; syscall(__NR_ptrace, 0x4206, r[1], 0, 0); syscall(__NR_ptrace, 0x4207, r[1]); syscall(__NR_ptrace, 0x20, r[1], 0, 0); res = syscall(__NR_socket, 0xa, 0x2100000000000002, 0); if (res != -1) r[2] = res; res = syscall(__NR_socket, 0x10, 3, 6); if (res != -1) r[3] = res; *(uint16_t*)0x20000080 = 0x10; *(uint16_t*)0x20000082 = 0; *(uint32_t*)0x20000084 = 0; *(uint32_t*)0x20000088 = 1; syscall(__NR_bind, r[3], 0x20000080, 0xc); *(uint8_t*)0x200002c0 = 0xfe; *(uint8_t*)0x200002c1 = 0x80; *(uint8_t*)0x200002c2 = 0; *(uint8_t*)0x200002c3 = 0; *(uint8_t*)0x200002c4 = 0; *(uint8_t*)0x200002c5 = 0; *(uint8_t*)0x200002c6 = 0; *(uint8_t*)0x200002c7 = 0; *(uint8_t*)0x200002c8 = 0; *(uint8_t*)0x200002c9 = 0; *(uint8_t*)0x200002ca = 0; *(uint8_t*)0x200002cb = 0; *(uint8_t*)0x200002cc = 0; *(uint8_t*)0x200002cd = 0; *(uint8_t*)0x200002ce = 0; *(uint8_t*)0x200002cf = 0xbb; *(uint64_t*)0x200002d0 = htobe64(0); *(uint64_t*)0x200002d8 = htobe64(1); *(uint16_t*)0x200002e0 = htobe16(0); *(uint16_t*)0x200002e2 = htobe16(0); *(uint16_t*)0x200002e4 = htobe16(0); *(uint16_t*)0x200002e6 = htobe16(0); *(uint16_t*)0x200002e8 = 0xa; *(uint8_t*)0x200002ea = 0; *(uint8_t*)0x200002eb = 0; *(uint8_t*)0x200002ec = 0; *(uint32_t*)0x200002f0 = 0; *(uint32_t*)0x200002f4 = 0; *(uint64_t*)0x200002f8 = 0; *(uint64_t*)0x20000300 = 0; *(uint64_t*)0x20000308 = 0; *(uint64_t*)0x20000310 = 0; *(uint64_t*)0x20000318 = 0; *(uint64_t*)0x20000320 = 0; *(uint64_t*)0x20000328 = 0; *(uint64_t*)0x20000330 = 0; *(uint64_t*)0x20000338 = 0; *(uint64_t*)0x20000340 = 0; *(uint64_t*)0x20000348 = 0; *(uint64_t*)0x20000350 = 0; *(uint32_t*)0x20000358 = 0; *(uint32_t*)0x2000035c = 0; *(uint8_t*)0x20000360 = 1; *(uint8_t*)0x20000361 = 0; *(uint8_t*)0x20000362 = 0; *(uint8_t*)0x20000363 = 0; *(uint32_t*)0x20000368 = htobe32(0xe0000001); *(uint32_t*)0x20000378 = htobe32(0); *(uint8_t*)0x2000037c = 0x2b; *(uint16_t*)0x20000380 = 0; *(uint64_t*)0x20000384 = htobe64(0); *(uint64_t*)0x2000038c = htobe64(1); *(uint32_t*)0x20000394 = 0; *(uint8_t*)0x20000398 = 0; *(uint8_t*)0x20000399 = 0; *(uint8_t*)0x2000039a = 3; *(uint32_t*)0x2000039c = 0; *(uint32_t*)0x200003a0 = 0; *(uint32_t*)0x200003a4 = 0; syscall(__NR_setsockopt, r[2], 0x29, 0x23, 0x200002c0, 0xe8); *(uint16_t*)0x20000280 = 0xa; *(uint16_t*)0x20000282 = htobe16(0x4e20); *(uint32_t*)0x20000284 = 0; *(uint8_t*)0x20000288 = 0xfe; *(uint8_t*)0x20000289 = 0x80; *(uint8_t*)0x2000028a = 0; *(uint8_t*)0x2000028b = 0; *(uint8_t*)0x2000028c = 0; *(uint8_t*)0x2000028d = 0; *(uint8_t*)0x2000028e = 0; *(uint8_t*)0x2000028f = 0; *(uint8_t*)0x20000290 = 0; *(uint8_t*)0x20000291 = 0; *(uint8_t*)0x20000292 = 0; *(uint8_t*)0x20000293 = 0; *(uint8_t*)0x20000294 = 0; *(uint8_t*)0x20000295 = 0; *(uint8_t*)0x20000296 = 0; *(uint8_t*)0x20000297 = 0xaa; *(uint32_t*)0x20000298 = 0; syscall(__NR_sendto, r[2], 0x200001c0, 0, 0, 0x20000280, 0x1c); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); for (;;) { loop(); } }