// https://syzkaller.appspot.com/bug?id=38933ca8abb1b8f0ee10c430f3a6c1f6a68a2519 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #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_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); \ } uint64_t r[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); install_segv_handler(); intptr_t res = 0; NONFAILING(memcpy((void*)0x20000100, "/dev/vhci\000", 10)); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000100ul, 0x8002ul, 0); if (res != -1) r[0] = res; NONFAILING(*(uint8_t*)0x20000000 = -1); NONFAILING(*(uint8_t*)0x20000001 = 0); syscall(__NR_write, r[0], 0x20000000ul, 2ul); NONFAILING(*(uint8_t*)0x20000040 = 4); NONFAILING(*(uint8_t*)0x20000041 = 0x22); NONFAILING(*(uint8_t*)0x20000042 = 0xe); NONFAILING(*(uint8_t*)0x20000043 = -1); NONFAILING(*(uint8_t*)0x20000044 = -1); NONFAILING(*(uint8_t*)0x20000045 = -1); NONFAILING(*(uint8_t*)0x20000046 = -1); NONFAILING(*(uint8_t*)0x20000047 = -1); NONFAILING(*(uint8_t*)0x20000048 = -1); NONFAILING(*(uint8_t*)0x20000049 = 0xc); NONFAILING(*(uint8_t*)0x2000004a = 9); NONFAILING(memcpy((void*)0x2000004b, "\x3a\x74\x93", 3)); NONFAILING(*(uint16_t*)0x2000004e = 6); NONFAILING(*(uint8_t*)0x20000050 = 8); syscall(__NR_write, r[0], 0x20000040ul, 0x11ul); return 0; }