// https://syzkaller.appspot.com/bug?id=c4117efdec586bbccac5428cce624863690bd3b8 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #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_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 use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); install_segv_handler(); use_temporary_dir(); intptr_t res = 0; NONFAILING(memcpy((void*)0x20000280, "/dev/infiniband/rdma_cm\000", 24)); res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000280, 2, 0); if (res != -1) r[0] = res; NONFAILING(*(uint32_t*)0x20000080 = 0); NONFAILING(*(uint16_t*)0x20000084 = 0x18); NONFAILING(*(uint16_t*)0x20000086 = 0xfa00); NONFAILING(*(uint64_t*)0x20000088 = 0); NONFAILING(*(uint64_t*)0x20000090 = 0x200002c0); NONFAILING(*(uint16_t*)0x20000098 = 2); NONFAILING(*(uint8_t*)0x2000009a = 0); NONFAILING(*(uint8_t*)0x2000009b = 0); NONFAILING(*(uint8_t*)0x2000009c = 0); NONFAILING(*(uint8_t*)0x2000009d = 0); NONFAILING(*(uint8_t*)0x2000009e = 0); NONFAILING(*(uint8_t*)0x2000009f = 0); res = syscall(__NR_write, r[0], 0x20000080, 0x20); if (res != -1) NONFAILING(r[1] = *(uint32_t*)0x200002c0); NONFAILING(*(uint32_t*)0x200000c0 = 0x14); NONFAILING(*(uint16_t*)0x200000c4 = 0x88); NONFAILING(*(uint16_t*)0x200000c6 = 0xfa00); NONFAILING(*(uint32_t*)0x200000c8 = r[1]); NONFAILING(*(uint16_t*)0x200000cc = 0x30); NONFAILING(*(uint16_t*)0x200000ce = 0); NONFAILING(*(uint16_t*)0x200000d0 = 0x1b); NONFAILING(*(uint16_t*)0x200000d2 = htobe16(0)); NONFAILING(*(uint32_t*)0x200000d4 = htobe32(0)); NONFAILING(memcpy( (void*)0x200000d8, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", 16)); NONFAILING(*(uint64_t*)0x200000e8 = htobe64(0)); NONFAILING(*(uint64_t*)0x200000f0 = htobe64(0)); NONFAILING(*(uint64_t*)0x200000f8 = 0); syscall(__NR_write, r[0], 0x200000c0, 0x90); return 0; }