// https://syzkaller.appspot.com/bug?id=3e99f9b4ca4807bb541159f3cd1c0776f6598ee8 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #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 static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* uctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _longjmp(segv_env, 1); } doexit(sig); } static void install_segv_handler() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } static void execute_one(); extern unsigned long long procid; void loop() { while (1) { execute_one(); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one() { long res = 0; res = syscall(__NR_socket, 0x26, 5, 0); if (res != -1) r[0] = res; NONFAILING(*(uint16_t*)0x20000080 = 0x26); NONFAILING(memcpy((void*)0x20000082, "\x68\x61\x73\x68\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 14)); NONFAILING(*(uint32_t*)0x20000090 = 0); NONFAILING(*(uint32_t*)0x20000094 = 0); NONFAILING(memcpy((void*)0x20000098, "\x63\x72\x79\x70\x74\x64\x28\x73\x68\x61\x33\x2d\x33\x38" "\x34\x2d\x67\x65\x6e\x65\x72\x69\x63\x29\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", 64)); syscall(__NR_bind, r[0], 0x20000080, 0x58); res = syscall(__NR_accept, r[0], 0, 0); if (res != -1) r[1] = res; NONFAILING(*(uint64_t*)0x20000f40 = 0); NONFAILING(*(uint32_t*)0x20000f48 = 0); NONFAILING(*(uint64_t*)0x20000f50 = 0x20000640); NONFAILING(*(uint64_t*)0x20000f58 = 0x107); NONFAILING(*(uint64_t*)0x20000f60 = 0x20000680); NONFAILING(*(uint64_t*)0x20000f68 = 0x66); NONFAILING(*(uint32_t*)0x20000f70 = 0); syscall(__NR_sendmmsg, r[1], 0x20000f40, 0xc95d03eb8aea92df, 0); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); install_segv_handler(); for (;;) { loop(); } }