// https://syzkaller.appspot.com/bug?id=ffdf2711c935a1b72550b3334420d7a3b168f335 // 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[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_one() { long res = 0; res = syscall(__NR_inotify_init1, 0); 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, 0xf, 3, 2); if (res != -1) r[2] = res; *(uint64_t*)0x20f56000 = 0; *(uint32_t*)0x20f56008 = 0; *(uint64_t*)0x20f56010 = 0x208feff0; *(uint64_t*)0x208feff0 = 0x20000040; *(uint8_t*)0x20000040 = 2; *(uint8_t*)0x20000041 = 3; *(uint8_t*)0x20000042 = 0; *(uint8_t*)0x20000043 = 9; *(uint16_t*)0x20000044 = 0x10; *(uint16_t*)0x20000046 = 0; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x2000004c = 0; *(uint16_t*)0x20000050 = 2; *(uint16_t*)0x20000052 = 0x13; *(uint8_t*)0x20000054 = 2; *(uint8_t*)0x20000055 = 0; *(uint16_t*)0x20000056 = 0; *(uint32_t*)0x20000058 = 0; *(uint32_t*)0x2000005c = 0; *(uint16_t*)0x20000060 = 5; *(uint16_t*)0x20000062 = 6; *(uint8_t*)0x20000064 = 0; *(uint8_t*)0x20000065 = 0; *(uint16_t*)0x20000066 = 0; *(uint16_t*)0x20000068 = 0xa; *(uint16_t*)0x2000006a = htobe16(0); *(uint32_t*)0x2000006c = 0; *(uint8_t*)0x20000070 = 0; *(uint8_t*)0x20000071 = 0; *(uint8_t*)0x20000072 = 0; *(uint8_t*)0x20000073 = 0; *(uint8_t*)0x20000074 = 0; *(uint8_t*)0x20000075 = 0; *(uint8_t*)0x20000076 = 0; *(uint8_t*)0x20000077 = 0; *(uint8_t*)0x20000078 = 0; *(uint8_t*)0x20000079 = 0; *(uint8_t*)0x2000007a = 0; *(uint8_t*)0x2000007b = 0; *(uint8_t*)0x2000007c = 0; *(uint8_t*)0x2000007d = 0; *(uint8_t*)0x2000007e = 0; *(uint8_t*)0x2000007f = 0; *(uint32_t*)0x20000080 = 0; *(uint16_t*)0x20000088 = 2; *(uint16_t*)0x2000008a = 1; *(uint32_t*)0x2000008c = htobe32(0); *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000091 = 0; *(uint8_t*)0x20000092 = 0; *(uint8_t*)0x20000093 = 2; *(uint32_t*)0x20000094 = 0; *(uint16_t*)0x20000098 = 5; *(uint16_t*)0x2000009a = 5; *(uint8_t*)0x2000009c = 0; *(uint8_t*)0x2000009d = 0; *(uint16_t*)0x2000009e = 0; *(uint16_t*)0x200000a0 = 0xa; *(uint16_t*)0x200000a2 = htobe16(0); *(uint32_t*)0x200000a4 = 0; *(uint8_t*)0x200000a8 = -1; *(uint8_t*)0x200000a9 = 1; *(uint8_t*)0x200000aa = 0; *(uint8_t*)0x200000ab = 0; *(uint8_t*)0x200000ac = 0; *(uint8_t*)0x200000ad = 0; *(uint8_t*)0x200000ae = 0; *(uint8_t*)0x200000af = 0; *(uint8_t*)0x200000b0 = 0; *(uint8_t*)0x200000b1 = 0; *(uint8_t*)0x200000b2 = 0; *(uint8_t*)0x200000b3 = 0; *(uint8_t*)0x200000b4 = 0; *(uint8_t*)0x200000b5 = 0; *(uint8_t*)0x200000b6 = 0; *(uint8_t*)0x200000b7 = 1; *(uint32_t*)0x200000b8 = 0; *(uint64_t*)0x208feff8 = 0x80; *(uint64_t*)0x20f56018 = 1; *(uint64_t*)0x20f56020 = 0; *(uint64_t*)0x20f56028 = 0; *(uint32_t*)0x20f56030 = 0; syscall(__NR_sendmsg, r[2], 0x20f56000, 0); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); for (;;) { loop(); } }