// https://syzkaller.appspot.com/bug?id=8fa72f6bf8ed852bab30490a709dbb7916a68eba // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_bpf #define __NR_bpf 321 #endif #ifndef __NR_io_uring_enter #define __NR_io_uring_enter 426 #endif #ifndef __NR_io_uring_setup #define __NR_io_uring_setup 425 #endif #ifndef __NR_seccomp #define __NR_seccomp 317 #endif 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_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(...) \ ({ \ 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; \ }) uint64_t r[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; install_segv_handler(); intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // signalfd arguments: [ // fd: fd (resource) // mask: ptr[in, sigset_t] { // sigset_t { // mask: array[intptr] { // intptr = 0x7fffffff (8 bytes) // } // } // } // size: len = 0x8 (8 bytes) // ] // returns fd NONFAILING(*(uint64_t*)0x2000000002c0 = 0x7fffffff); syscall(__NR_signalfd, /*fd=*/(intptr_t)-1, /*mask=*/0x2000000002c0ul, /*size=*/8ul); // prctl$PR_SET_MM_MAP arguments: [ // option: const = 0x23 (8 bytes) // opt: const = 0xe (8 bytes) // arg: ptr[in, prctl_mm_map] { // prctl_mm_map { // start_code: VMA[0x1000] // end_code: VMA[0x3000] // start_data: VMA[0x4000] // end_data: VMA[0x4000] // start_brk: VMA[0x4000] // brk: VMA[0x3000] // start_stack: VMA[0x3000] // arg_start: VMA[0xc000] // arg_end: VMA[0x1000] // env_start: VMA[0x1000] // env_end: VMA[0x2000] // auxv: nil // auxv_size: bytesize = 0x0 (4 bytes) // exe_fd: fd (resource) // } // } // len: bytesize = 0x68 (8 bytes) // ] NONFAILING(*(uint64_t*)0x200000000080 = 0x200000ff0000); NONFAILING(*(uint64_t*)0x200000000088 = 0x200000ffd000); NONFAILING(*(uint64_t*)0x200000000090 = 0x200000ffc000); NONFAILING(*(uint64_t*)0x200000000098 = 0x200000ffc000); NONFAILING(*(uint64_t*)0x2000000000a0 = 0x200000ff8000); NONFAILING(*(uint64_t*)0x2000000000a8 = 0x200000ff8000); NONFAILING(*(uint64_t*)0x2000000000b0 = 0x200000ffb000); NONFAILING(*(uint64_t*)0x2000000000b8 = 0x20000068c000); NONFAILING(*(uint64_t*)0x2000000000c0 = 0x200000817000); NONFAILING(*(uint64_t*)0x2000000000c8 = 0x200000ffa000); NONFAILING(*(uint64_t*)0x2000000000d0 = 0x200000ffa000); NONFAILING(*(uint64_t*)0x2000000000d8 = 0); NONFAILING(*(uint32_t*)0x2000000000e0 = 0); NONFAILING(*(uint32_t*)0x2000000000e4 = -1); syscall(__NR_prctl, /*option=*/0x23ul, /*opt=*/0xeul, /*arg=*/0x200000000080ul, /*len=*/0x68ul, 0); // sendmsg$NFT_BATCH arguments: [ // fd: sock_nl_netfilter (resource) // msg: ptr[in, msghdr_netlink[nft_batch_msg]] { // msghdr_netlink[nft_batch_msg] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: nil // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] NONFAILING(*(uint64_t*)0x200000000080 = 0); NONFAILING(*(uint32_t*)0x200000000088 = 0); NONFAILING(*(uint64_t*)0x200000000090 = 0); NONFAILING(*(uint64_t*)0x200000000098 = 1); NONFAILING(*(uint64_t*)0x2000000000a0 = 0); NONFAILING(*(uint64_t*)0x2000000000a8 = 0); NONFAILING(*(uint32_t*)0x2000000000b0 = 0); syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000000080ul, /*f=*/0ul); // io_uring_setup arguments: [ // entries: int32 = 0x7 (4 bytes) // params: ptr[inout, io_uring_params] { // io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x723a (4 bytes) // flags: io_uring_setup_flags = 0xc000 (4 bytes) // sq_thread_cpu: int32 = 0x8 (4 bytes) // sq_thread_idle: int32 = 0xc1 (4 bytes) // features: int32 = 0x0 (4 bytes) // wq_fd: fd_io_uring (resource) // resv: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} (length 0xc) // sq_off: io_sqring_offsets { // head: int32 = 0x0 (4 bytes) // tail: int32 = 0x0 (4 bytes) // ring_mask: int32 = 0x0 (4 bytes) // ring_entries: int32 = 0x0 (4 bytes) // flags: int32 = 0x0 (4 bytes) // dropped: int32 = 0x0 (4 bytes) // array: int32 = 0x0 (4 bytes) // resv1: int32 = 0x0 (4 bytes) // user_addr: int64 = 0x0 (8 bytes) // } // cq_off: io_cqring_offsets { // head: int32 = 0x0 (4 bytes) // tail: int32 = 0x0 (4 bytes) // ring_mask: int32 = 0x0 (4 bytes) // ring_entries: int32 = 0x0 (4 bytes) // overflow: int32 = 0x0 (4 bytes) // cqes: int32 = 0x0 (4 bytes) // flags: int32 = 0x0 (4 bytes) // resv1: int32 = 0x0 (4 bytes) // user_addr: int64 = 0x0 (8 bytes) // } // } // } // ] // returns fd_io_uring NONFAILING(*(uint32_t*)0x200000000044 = 0x723a); NONFAILING(*(uint32_t*)0x200000000048 = 0xc000); NONFAILING(*(uint32_t*)0x20000000004c = 8); NONFAILING(*(uint32_t*)0x200000000050 = 0xc1); NONFAILING(*(uint32_t*)0x200000000058 = -1); NONFAILING(memset((void*)0x20000000005c, 0, 12)); res = syscall(__NR_io_uring_setup, /*entries=*/7, /*params=*/0x200000000040ul); if (res != -1) r[0] = res; // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x12 (4 bytes) // ninsn: bytesize8 = 0x3 (4 bytes) // insns: nil // license: ptr[in, buffer] { // buffer: {73 79 7a 6b 61 6c 6c 65 72 00} (length 0xa) // } // loglev: int32 = 0x80000000 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x2e (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x0 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x0 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog NONFAILING(*(uint32_t*)0x200000000000 = 0x12); NONFAILING(*(uint32_t*)0x200000000004 = 3); NONFAILING(*(uint64_t*)0x200000000008 = 0); NONFAILING(*(uint64_t*)0x200000000010 = 0x200000000240); NONFAILING(memcpy((void*)0x200000000240, "syzkaller\000", 10)); NONFAILING(*(uint32_t*)0x200000000018 = 0x80000000); NONFAILING(*(uint32_t*)0x20000000001c = 0); NONFAILING(*(uint64_t*)0x200000000020 = 0); NONFAILING(*(uint32_t*)0x200000000028 = 0); NONFAILING(*(uint32_t*)0x20000000002c = 0); NONFAILING(memset((void*)0x200000000030, 0, 16)); NONFAILING(*(uint32_t*)0x200000000040 = 0); NONFAILING(*(uint32_t*)0x200000000044 = 0x2e); NONFAILING(*(uint32_t*)0x200000000048 = 0); NONFAILING(*(uint32_t*)0x20000000004c = 0); NONFAILING(*(uint64_t*)0x200000000050 = 0); NONFAILING(*(uint32_t*)0x200000000058 = 0); NONFAILING(*(uint32_t*)0x20000000005c = 0); NONFAILING(*(uint64_t*)0x200000000060 = 0); NONFAILING(*(uint32_t*)0x200000000068 = 0); NONFAILING(*(uint32_t*)0x20000000006c = 0); NONFAILING(*(uint32_t*)0x200000000070 = 0); NONFAILING(*(uint32_t*)0x200000000074 = 0); NONFAILING(*(uint64_t*)0x200000000078 = 0); NONFAILING(*(uint64_t*)0x200000000080 = 0); NONFAILING(*(uint32_t*)0x200000000088 = 0x10); NONFAILING(*(uint32_t*)0x20000000008c = 0); NONFAILING(*(uint32_t*)0x200000000090 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000000ul, /*size=*/0x94ul); // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {16} (length 0x1) // } // } // } // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map NONFAILING(memset((void*)0x200000000000, 22, 1)); syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x200000000000ul, /*size=*/0x50ul); // io_uring_enter arguments: [ // fd: fd_io_uring (resource) // to_submit: int32 = 0x2219 (4 bytes) // min_complete: int32 = 0x7721 (4 bytes) // flags: io_uring_enter_flags = 0x16 (8 bytes) // sigmask: nil // size: len = 0x0 (8 bytes) // ] syscall( __NR_io_uring_enter, /*fd=*/r[0], /*to_submit=*/0x2219, /*min_complete=*/0x7721, /*flags=IORING_ENTER_REGISTERED_RING|IORING_ENTER_SQ_WAIT|IORING_ENTER_SQ_WAKEUP*/ 0x16ul, /*sigmask=*/0ul, /*size=*/0ul); // seccomp$SECCOMP_SET_MODE_FILTER_LISTENER arguments: [ // op: const = 0x1 (8 bytes) // flags: seccomp_flags_listener = 0x7 (8 bytes) // arg: ptr[in, sock_fprog] { // sock_fprog { // len: len = 0x1 (2 bytes) // pad = 0x0 (6 bytes) // filter: ptr[in, array[sock_filter]] { // array[sock_filter] { // sock_filter { // code: int16 = 0x6 (2 bytes) // jt: int8 = 0x5 (1 bytes) // jf: int8 = 0x3 (1 bytes) // k: int32 = 0x7ffbffff (4 bytes) // } // } // } // } // } // ] // returns fd_seccomp NONFAILING(*(uint16_t*)0x200000000240 = 1); NONFAILING(*(uint64_t*)0x200000000248 = 0x200000000000); NONFAILING(*(uint16_t*)0x200000000000 = 6); NONFAILING(*(uint8_t*)0x200000000002 = 5); NONFAILING(*(uint8_t*)0x200000000003 = 3); NONFAILING(*(uint32_t*)0x200000000004 = 0x7ffbffff); syscall(__NR_seccomp, /*op=*/1ul, /*flags=*/7ul, /*arg=*/0x200000000240ul); return 0; }