// https://syzkaller.appspot.com/bug?id=a7a41a7f641844dd94c17c63f0d9ccf68884083a // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #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* ctx) { 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); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; 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); \ } #define __syscall syscall uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(SYS_mmap, 0x20000000, 0x1000000, 3, 0x1012, -1, 0, 0); install_segv_handler(); intptr_t res = 0; NONFAILING(*(uint32_t*)0x20000000 = 0); NONFAILING(*(uint32_t*)0x20000004 = 0); NONFAILING(*(uint64_t*)0x20000008 = 0); NONFAILING(*(uint64_t*)0x20000010 = 3); syscall(SYS_ioctl, -1, 0x80185760, 0x20000000); res = syscall(SYS_socket, 0x18, 1, 0); if (res != -1) r[0] = res; NONFAILING(*(uint32_t*)0x200000c0 = 0); NONFAILING(*(uint32_t*)0x200000c4 = 0); NONFAILING(*(uint32_t*)0x200000c8 = 0x1ff); NONFAILING(*(uint32_t*)0x200000cc = 0); NONFAILING(memcpy((void*)0x200000d0, "\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x20\x00\x00\x00" "\x00\x00\x00\x00\x00\x00", 20)); NONFAILING(*(uint32_t*)0x200000e4 = 0); NONFAILING(*(uint32_t*)0x200000e8 = 0); syscall(SYS_ioctl, -1, 0x802c7414, 0x200000c0); NONFAILING(*(uint16_t*)0x200000c0 = 0x18e6); NONFAILING(*(uint8_t*)0x200000c2 = 7); NONFAILING(*(uint32_t*)0x200000c4 = 0); syscall(SYS_connect, -1, 0x200000c0, 0x1c); syscall(SYS_close, r[0]); res = syscall(SYS_socket, 0x18, 3, 0); if (res != -1) r[1] = res; res = syscall(SYS_socket, 0x18, 3, 0); if (res != -1) r[2] = res; NONFAILING(memcpy((void*)0x20000040, "\xd5\xff\x96\x28", 4)); syscall(SYS_setsockopt, r[2], 0x29, 0x26, 0x20000040, 4); syscall(SYS_mprotect, 0x20000000, 0x800000, 5); NONFAILING(memcpy((void*)0x20000000, "\xeb\xff\xcb\xff\x13\xb9\xfd\x81\x2e\xaa\x4e\x71\x30\x48" "\xe6\x99\x31\x92\x96\x48", 20)); syscall(SYS_setsockopt, r[1], 0x29, 0x2e, 0x20000000, 0x14); NONFAILING(*(uint16_t*)0x200000c0 = 0); NONFAILING(*(uint8_t*)0x200000c2 = 7); NONFAILING(*(uint32_t*)0x200000c4 = 0); syscall(SYS_connect, r[0], 0x200000c0, 0x1c); NONFAILING(memcpy((void*)0x20000100, "\x8c\x65", 2)); syscall(SYS_write, r[1], 0x20000100, 0x6d2); return 0; }