// https://syzkaller.appspot.com/bug?id=a5b80da4b4e7ebf2467ad2c3c4eb83d86f7163e9 // 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 #include #include __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include #include static uintptr_t syz_open_procfs(uintptr_t a0, uintptr_t a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == (uintptr_t)-1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); unshare(CLONE_NEWNS); unshare(CLONE_NEWIPC); unshare(CLONE_IO); } static int do_sandbox_none(int executor_pid, bool enable_tun) { int pid = fork(); if (pid) return pid; sandbox_common(); loop(); doexit(1); } #ifndef __NR_preadv #define __NR_preadv 333 #endif #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_timer_create #define __NR_timer_create 259 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 long r[19]; void loop() { memset(r, -1, sizeof(r)); r[0] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); *(uint32_t*)0x20a06fa0 = (uint32_t)0x0; *(uint32_t*)0x20a06fa4 = (uint32_t)0x1c; *(uint32_t*)0x20a06fa8 = (uint32_t)0x100000; *(uint32_t*)0x20a06fac = (uint32_t)0x0; *(uint64_t*)0x20a06fb8 = (uint64_t)0x0; *(uint64_t*)0x20a06fc0 = (uint64_t)0x0; *(uint64_t*)0x20a06fc8 = (uint64_t)0x0; *(uint64_t*)0x20a06fd0 = (uint64_t)0x0; *(uint64_t*)0x20a06fd8 = (uint64_t)0x0; *(uint64_t*)0x20a06fe0 = (uint64_t)0x0; *(uint64_t*)0x20a06fe8 = (uint64_t)0x0; *(uint64_t*)0x20a06ff0 = (uint64_t)0x0; r[13] = syscall(__NR_timer_create, 0x7ul, 0x20a06fa0ul, 0x20dd2ffcul); memcpy((void*)0x20337ff2, "\x74\x69\x6d\x65\x72\x73\x00", 7); r[15] = syz_open_procfs(0x0ul, 0x20337ff2ul); *(uint32_t*)0x205e2ff0 = (uint32_t)0x20fa6000; *(uint32_t*)0x205e2ff4 = (uint32_t)0x64; r[18] = syscall(__NR_preadv, r[15], 0x205e2ff0ul, 0x1ul, 0x0ul); } int main() { int pid = do_sandbox_none(0, false); int status = 0; while (waitpid(pid, &status, __WALL) != pid) { } return 0; }