// https://syzkaller.appspot.com/bug?id=07b4a8305e6975f3978c0e3adf8a157fa7914416 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _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(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } #define CAST static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // pipe arguments: [ // pipefd: nil // ] NONFAILING(((intptr_t (*)(intptr_t))CAST(pipe))(/*pipefd=*/0)); // openat$pf arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: nil // flags: open_flags = 0x2 (8 bytes) // mode: const = 0x0 (8 bytes) // ] // returns fd_pf NONFAILING(( (intptr_t (*)(intptr_t, intptr_t, intptr_t, intptr_t))CAST(openat))( /*fd=*/0xffffffffffffff9c, /*file=*/0, /*flags=O_RDWR*/ 2, /*mode=*/0)); // sysctl$vfs_nfs arguments: [ // name: ptr[in, ctl_vfs_nfs] { // ctl_vfs_nfs { // n1: const = 0xa (4 bytes) // n2: const = 0x2 (4 bytes) // n3: ctl_vfs_nfs_flags = 0x3 (4 bytes) // } // } // namelen: bytesize4 = 0xf (8 bytes) // oldp: nil // oldlenp: nil // newp: nil // newlen: len = 0xfffffffffffffe70 (8 bytes) // ] NONFAILING(*(uint32_t*)0x200000000000 = 0xa); NONFAILING(*(uint32_t*)0x200000000004 = 2); NONFAILING(*(uint32_t*)0x200000000008 = 3); NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))CAST(sysctl))( /*name=*/0x200000000000, /*namelen=*/0xf, /*oldp=*/0, /*oldlenp=*/0, /*newp=*/0, /*newlen=*/0xfffffffffffffe70)); // ioctl$VMM_IOC_WRITEREGS arguments: [ // fd: fd_vmm (resource) // cmd: const = 0x82485608 (8 bytes) // arg: ptr[in, vm_rwregs_params] { // vm_rwregs_params { // vrwp_vm_id: int32 = 0x3 (4 bytes) // vrwp_vcpu_id: int32 = 0x6 (4 bytes) // vrwp_mask: int64 = 0x200000401 (8 bytes) // vrwp_regs: vcpu_reg_state { // vrs_gprs: array[int64] { // int64 = 0x6 (8 bytes) // int64 = 0xff (8 bytes) // int64 = 0x3 (8 bytes) // int64 = 0xffffffffffffffff (8 bytes) // int64 = 0x7 (8 bytes) // int64 = 0x200 (8 bytes) // int64 = 0x80000001 (8 bytes) // int64 = 0x9 (8 bytes) // int64 = 0x2 (8 bytes) // int64 = 0x0 (8 bytes) // int64 = 0xf681 (8 bytes) // int64 = 0x8 (8 bytes) // int64 = 0x7fff (8 bytes) // int64 = 0x692 (8 bytes) // int64 = 0x1 (8 bytes) // int64 = 0x4 (8 bytes) // int64 = 0x40000000000002 (8 bytes) // int64 = 0x2 (8 bytes) // } // vrs_crs: array[int64] { // int64 = 0x3 (8 bytes) // int64 = 0x7fffffff (8 bytes) // int64 = 0x3 (8 bytes) // int64 = 0x6 (8 bytes) // int64 = 0x8001 (8 bytes) // int64 = 0x5 (8 bytes) // int64 = 0x18000000 (8 bytes) // int64 = 0xe (8 bytes) // int64 = 0x5 (8 bytes) // int64 = 0xfffffffffffffffd (8 bytes) // } // vrs_msrs: array[int64] { // int64 = 0x2 (8 bytes) // int64 = 0x2 (8 bytes) // int64 = 0x80001 (8 bytes) // int64 = 0x80 (8 bytes) // int64 = 0x1000 (8 bytes) // int64 = 0xfffffffffffffffe (8 bytes) // int64 = 0x1000 (8 bytes) // } // vrs_drs: array[int64] { // int64 = 0xfffd (8 bytes) // int64 = 0x6 (8 bytes) // int64 = 0x2000000008000 (8 bytes) // int64 = 0x2 (8 bytes) // int64 = 0xd9 (8 bytes) // int64 = 0x202007 (8 bytes) // } // vrs_sregs: array[vcpu_segment_info] { // vcpu_segment_info { // vsi_sel: int16 = 0x9 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x8 (4 bytes) // vsi_ar: int32 = 0xce (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x400 (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0x7 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x1 (4 bytes) // vsi_ar: int32 = 0x3 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x20000400 (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0x1 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0xfc (4 bytes) // vsi_ar: int32 = 0x4e0ec4e7 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x9 (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0x6 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0xeb82 (4 bytes) // vsi_ar: int32 = 0x7fffffff (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x1b (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0xd (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x40000003 (4 bytes) // vsi_ar: int32 = 0xfffffffa (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x7 (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0x99 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x1 (4 bytes) // vsi_ar: int32 = 0x2 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x1 (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0x4 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0xa (4 bytes) // vsi_ar: int32 = 0x1 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x6 (8 bytes) // } // vcpu_segment_info { // vsi_sel: int16 = 0x7ff (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x6fb (4 bytes) // vsi_ar: int32 = 0x10000 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x2 (8 bytes) // } // } // vrs_gdtr: vcpu_segment_info { // vsi_sel: int16 = 0x7fff (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x40000 (4 bytes) // vsi_ar: int32 = 0xc687 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0x6 (8 bytes) // } // vrs_idtr: vcpu_segment_info { // vsi_sel: int16 = 0x9 (2 bytes) // pad = 0x0 (2 bytes) // vsi_limit: int32 = 0x4 (4 bytes) // vsi_ar: int32 = 0x80000000 (4 bytes) // pad = 0x0 (4 bytes) // vsi_base: int64 = 0xfffffffffffffffc (8 bytes) // } // } // } // } // ] NONFAILING(*(uint32_t*)0x200000000100 = 3); NONFAILING(*(uint32_t*)0x200000000104 = 6); NONFAILING(*(uint64_t*)0x200000000108 = 0x200000401); NONFAILING(*(uint64_t*)0x200000000110 = 6); NONFAILING(*(uint64_t*)0x200000000118 = 0xff); NONFAILING(*(uint64_t*)0x200000000120 = 3); NONFAILING(*(uint64_t*)0x200000000128 = -1); NONFAILING(*(uint64_t*)0x200000000130 = 7); NONFAILING(*(uint64_t*)0x200000000138 = 0x200); NONFAILING(*(uint64_t*)0x200000000140 = 0x80000001); NONFAILING(*(uint64_t*)0x200000000148 = 9); NONFAILING(*(uint64_t*)0x200000000150 = 2); NONFAILING(*(uint64_t*)0x200000000158 = 0); NONFAILING(*(uint64_t*)0x200000000160 = 0xf681); NONFAILING(*(uint64_t*)0x200000000168 = 8); NONFAILING(*(uint64_t*)0x200000000170 = 0x7fff); NONFAILING(*(uint64_t*)0x200000000178 = 0x692); NONFAILING(*(uint64_t*)0x200000000180 = 1); NONFAILING(*(uint64_t*)0x200000000188 = 4); NONFAILING(*(uint64_t*)0x200000000190 = 0x40000000000002); NONFAILING(*(uint64_t*)0x200000000198 = 2); NONFAILING(*(uint64_t*)0x2000000001a0 = 3); NONFAILING(*(uint64_t*)0x2000000001a8 = 0x7fffffff); NONFAILING(*(uint64_t*)0x2000000001b0 = 3); NONFAILING(*(uint64_t*)0x2000000001b8 = 6); NONFAILING(*(uint64_t*)0x2000000001c0 = 0x8001); NONFAILING(*(uint64_t*)0x2000000001c8 = 5); NONFAILING(*(uint64_t*)0x2000000001d0 = 0x18000000); NONFAILING(*(uint64_t*)0x2000000001d8 = 0xe); NONFAILING(*(uint64_t*)0x2000000001e0 = 5); NONFAILING(*(uint64_t*)0x2000000001e8 = 0xfffffffffffffffd); NONFAILING(*(uint64_t*)0x2000000001f0 = 2); NONFAILING(*(uint64_t*)0x2000000001f8 = 2); NONFAILING(*(uint64_t*)0x200000000200 = 0x80001); NONFAILING(*(uint64_t*)0x200000000208 = 0x80); NONFAILING(*(uint64_t*)0x200000000210 = 0x1000); NONFAILING(*(uint64_t*)0x200000000218 = 0xfffffffffffffffe); NONFAILING(*(uint64_t*)0x200000000220 = 0x1000); NONFAILING(*(uint64_t*)0x200000000228 = 0xfffd); NONFAILING(*(uint64_t*)0x200000000230 = 6); NONFAILING(*(uint64_t*)0x200000000238 = 0x2000000008000); NONFAILING(*(uint64_t*)0x200000000240 = 2); NONFAILING(*(uint64_t*)0x200000000248 = 0xd9); NONFAILING(*(uint64_t*)0x200000000250 = 0x202007); NONFAILING(*(uint16_t*)0x200000000258 = 9); NONFAILING(*(uint32_t*)0x20000000025c = 8); NONFAILING(*(uint32_t*)0x200000000260 = 0xce); NONFAILING(*(uint64_t*)0x200000000268 = 0x400); NONFAILING(*(uint16_t*)0x200000000270 = 7); NONFAILING(*(uint32_t*)0x200000000274 = 1); NONFAILING(*(uint32_t*)0x200000000278 = 3); NONFAILING(*(uint64_t*)0x200000000280 = 0x20000400); NONFAILING(*(uint16_t*)0x200000000288 = 1); NONFAILING(*(uint32_t*)0x20000000028c = 0xfc); NONFAILING(*(uint32_t*)0x200000000290 = 0x4e0ec4e7); NONFAILING(*(uint64_t*)0x200000000298 = 9); NONFAILING(*(uint16_t*)0x2000000002a0 = 6); NONFAILING(*(uint32_t*)0x2000000002a4 = 0xeb82); NONFAILING(*(uint32_t*)0x2000000002a8 = 0x7fffffff); NONFAILING(*(uint64_t*)0x2000000002b0 = 0x1b); NONFAILING(*(uint16_t*)0x2000000002b8 = 0xd); NONFAILING(*(uint32_t*)0x2000000002bc = 0x40000003); NONFAILING(*(uint32_t*)0x2000000002c0 = 0xfffffffa); NONFAILING(*(uint64_t*)0x2000000002c8 = 7); NONFAILING(*(uint16_t*)0x2000000002d0 = 0x99); NONFAILING(*(uint32_t*)0x2000000002d4 = 1); NONFAILING(*(uint32_t*)0x2000000002d8 = 2); NONFAILING(*(uint64_t*)0x2000000002e0 = 1); NONFAILING(*(uint16_t*)0x2000000002e8 = 4); NONFAILING(*(uint32_t*)0x2000000002ec = 0xa); NONFAILING(*(uint32_t*)0x2000000002f0 = 1); NONFAILING(*(uint64_t*)0x2000000002f8 = 6); NONFAILING(*(uint16_t*)0x200000000300 = 0x7ff); NONFAILING(*(uint32_t*)0x200000000304 = 0x6fb); NONFAILING(*(uint32_t*)0x200000000308 = 0x10000); NONFAILING(*(uint64_t*)0x200000000310 = 2); NONFAILING(*(uint16_t*)0x200000000318 = 0x7fff); NONFAILING(*(uint32_t*)0x20000000031c = 0x40000); NONFAILING(*(uint32_t*)0x200000000320 = 0xc687); NONFAILING(*(uint64_t*)0x200000000328 = 6); NONFAILING(*(uint16_t*)0x200000000330 = 9); NONFAILING(*(uint32_t*)0x200000000334 = 4); NONFAILING(*(uint32_t*)0x200000000338 = 0x80000000); NONFAILING(*(uint64_t*)0x200000000340 = 0xfffffffffffffffc); NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t))CAST(ioctl))( /*fd=*/-1, /*cmd=*/0x82485608, /*arg=*/0x200000000100)); // sysctl$kern arguments: [ // name: ptr[in, ctl_kern] { // ctl_kern { // n1: const = 0x1 (4 bytes) // n2: ctl_kern_flags = 0x33 (4 bytes) // } // } // namelen: bytesize4 = 0x2 (8 bytes) // oldp: nil // oldlenp: nil // newp: nil // newlen: len = 0x0 (8 bytes) // ] NONFAILING(*(uint32_t*)0x200000000000 = 1); NONFAILING(*(uint32_t*)0x200000000004 = 0x33); NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))CAST(sysctl))( /*name=*/0x200000000000, /*namelen=*/2, /*oldp=*/0, /*oldlenp=*/0, /*newp=*/0, /*newlen=*/0)); // mprotect arguments: [ // addr: VMA[0x400000] // len: len = 0x400000 (8 bytes) // prot: mmap_prot = 0x4 (8 bytes) // ] NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t))CAST(mprotect))( /*addr=*/0x200000000000, /*len=*/0x400000, /*prot=PROT_EXEC*/ 4)); // sysctl$vm_swapencrypt arguments: [ // name: ptr[in, ctl_vm_swapencrypt] { // ctl_vm_swapencrypt { // n1: const = 0x2 (4 bytes) // n2: const = 0x5 (4 bytes) // n3: ctl_vm_swapencrypt_flags = 0x0 (4 bytes) // } // } // namelen: bytesize4 = 0x3 (8 bytes) // oldp: ptr[inout, buffer] { // buffer: {} (length 0x0) // } // oldlenp: ptr[inout, len] { // len = 0x0 (8 bytes) // } // newp: nil // newlen: len = 0x0 (8 bytes) // ] NONFAILING(*(uint32_t*)0x200000000000 = 2); NONFAILING(*(uint32_t*)0x200000000004 = 5); NONFAILING(*(uint32_t*)0x200000000008 = 0); NONFAILING(*(uint64_t*)0x200000000100 = 0); NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))CAST(sysctl))( /*name=*/0x200000000000, /*namelen=*/3, /*oldp=*/0x200000000040, /*oldlenp=*/0x200000000100, /*newp=*/0, /*newlen=*/0)); // sysctl$net_inet_tcp arguments: [ // name: nil // namelen: bytesize4 = 0x0 (8 bytes) // oldp: nil // oldlenp: nil // newp: nil // newlen: len = 0x0 (8 bytes) // ] NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))CAST(sysctl))(/*name=*/0, /*namelen=*/0, /*oldp=*/0, /*oldlenp=*/0, /*newp=*/0, /*newlen=*/0)); } int main(void) { NONFAILING(((intptr_t (*)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))CAST(mmap))( /*addr=*/0x200000000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/ 3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/ 0x1012, /*fd=*/-1, /*offset=*/0)); const char* reason; (void)reason; install_segv_handler(); loop(); return 0; }