// https://syzkaller.appspot.com/bug?id=fef8083f7f455d28eb08084264c5662a305e550b // 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 #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 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; \ }) 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 BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } const int kInitNetNsFd = 201; #define SIZEOF_IO_URING_SQE 64 #define SIZEOF_IO_URING_CQE 16 #define SQ_HEAD_OFFSET 0 #define SQ_TAIL_OFFSET 64 #define SQ_RING_MASK_OFFSET 256 #define SQ_RING_ENTRIES_OFFSET 264 #define SQ_FLAGS_OFFSET 276 #define SQ_DROPPED_OFFSET 272 #define CQ_HEAD_OFFSET 128 #define CQ_TAIL_OFFSET 192 #define CQ_RING_MASK_OFFSET 260 #define CQ_RING_ENTRIES_OFFSET 268 #define CQ_RING_OVERFLOW_OFFSET 284 #define CQ_FLAGS_OFFSET 280 #define CQ_CQES_OFFSET 320 struct io_sqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t flags; uint32_t dropped; uint32_t array; uint32_t resv1; uint64_t resv2; }; struct io_cqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t overflow; uint32_t cqes; uint64_t resv[2]; }; struct io_uring_params { uint32_t sq_entries; uint32_t cq_entries; uint32_t flags; uint32_t sq_thread_cpu; uint32_t sq_thread_idle; uint32_t features; uint32_t resv[4]; struct io_sqring_offsets sq_off; struct io_cqring_offsets cq_off; }; #define IORING_OFF_SQ_RING 0 #define IORING_OFF_SQES 0x10000000ULL #define IORING_SETUP_SQE128 (1U << 10) #define IORING_SETUP_CQE32 (1U << 11) static long syz_io_uring_setup(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { uint32_t entries = (uint32_t)a0; struct io_uring_params* setup_params = (struct io_uring_params*)a1; void** ring_ptr_out = (void**)a2; void** sqes_ptr_out = (void**)a3; setup_params->flags &= ~(IORING_SETUP_CQE32 | IORING_SETUP_SQE128); uint32_t fd_io_uring = syscall(__NR_io_uring_setup, entries, setup_params); uint32_t sq_ring_sz = setup_params->sq_off.array + setup_params->sq_entries * sizeof(uint32_t); uint32_t cq_ring_sz = setup_params->cq_off.cqes + setup_params->cq_entries * SIZEOF_IO_URING_CQE; uint32_t ring_sz = sq_ring_sz > cq_ring_sz ? sq_ring_sz : cq_ring_sz; *ring_ptr_out = mmap(0, ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd_io_uring, IORING_OFF_SQ_RING); uint32_t sqes_sz = setup_params->sq_entries * SIZEOF_IO_URING_SQE; *sqes_ptr_out = mmap(0, sqes_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd_io_uring, IORING_OFF_SQES); uint32_t* array = (uint32_t*)((uintptr_t)*ring_ptr_out + setup_params->sq_off.array); for (uint32_t index = 0; index < entries; index++) array[index] = index; return fd_io_uring; } static long syz_io_uring_submit(volatile long a0, volatile long a1, volatile long a2) { char* ring_ptr = (char*)a0; char* sqes_ptr = (char*)a1; char* sqe = (char*)a2; uint32_t sq_ring_mask = *(uint32_t*)(ring_ptr + SQ_RING_MASK_OFFSET); uint32_t* sq_tail_ptr = (uint32_t*)(ring_ptr + SQ_TAIL_OFFSET); uint32_t sq_tail = *sq_tail_ptr & sq_ring_mask; char* sqe_dest = sqes_ptr + sq_tail * SIZEOF_IO_URING_SQE; memcpy(sqe_dest, sqe, SIZEOF_IO_URING_SQE); uint32_t sq_tail_next = *sq_tail_ptr + 1; __atomic_store_n(sq_tail_ptr, sq_tail_next, __ATOMIC_RELEASE); return 0; } static long syz_memcpy_off(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4) { char* dest = (char*)a0; uint32_t dest_off = (uint32_t)a1; char* src = (char*)a2; uint32_t src_off = (uint32_t)a3; size_t n = (size_t)a4; return (long)memcpy(dest + dest_off, src + src_off, n); } static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto) { return syscall(__NR_socket, domain, type, proto); } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } #define USLEEP_FORKED_CHILD (3 * 50 * 1000) static long handle_clone_ret(long ret) { if (ret != 0) { __atomic_store_n(&clone_ongoing, 0, __ATOMIC_RELAXED); return ret; } usleep(USLEEP_FORKED_CHILD); syscall(__NR_exit, 0); while (1) { } } static long syz_clone(volatile long flags, volatile long stack, volatile long stack_len, volatile long ptid, volatile long ctid, volatile long tls) { long sp = (stack + stack_len) & ~15; __atomic_store_n(&clone_ongoing, 1, __ATOMIC_RELAXED); long ret = (long)syscall(__NR_clone, flags & ~CLONE_VM, sp, ptid, ctid, tls); return handle_clone_ret(ret); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); 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; } } } uint64_t r[7] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff, 0x0}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$nl_route arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_nl_route res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); if (res != -1) r[0] = res; // syz_clone arguments: [ // flags: clone_flags = 0x0 (8 bytes) // stack: nil // stack_len: bytesize = 0x0 (8 bytes) // parentid: nil // childtid: nil // tls: nil // ] // returns pid res = -1; NONFAILING(res = syz_clone(/*flags=*/0, /*stack=*/0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0)); if (res != -1) r[1] = res; // ptrace arguments: [ // req: ptrace_req = 0x10 (8 bytes) // pid: pid (resource) // ] syscall(__NR_ptrace, /*req=PTRACE_ATTACH*/ 0x10ul, /*pid=*/r[1], 0, 0); // bpf$BPF_PROG_RAW_TRACEPOINT_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]] { // bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]] { // type: bpf_raw_tracepoint_prog_types = 0x1 (4 bytes) // ninsn: bytesize8 = 0x4 (4 bytes) // insns: nil // license: nil // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x8 (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: // const = 0x0 (4 bytes) btf_fd: fd_btf (resource) func_info_rec_size: // const = 0x8 (4 bytes) func_info: nil func_info_cnt: len = 0x0 (4 // bytes) line_info_rec_size: const = 0x10 (4 bytes) line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: const = 0x0 (4 bytes) // attach_prog_fd: const = 0x0 (4 bytes) // 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_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog_raw_tracepoint NONFAILING(*(uint32_t*)0x200000000200 = 1); NONFAILING(*(uint32_t*)0x200000000204 = 4); NONFAILING(*(uint64_t*)0x200000000208 = 0); NONFAILING(*(uint64_t*)0x200000000210 = 0); NONFAILING(*(uint32_t*)0x200000000218 = 0); NONFAILING(*(uint32_t*)0x20000000021c = 0); NONFAILING(*(uint64_t*)0x200000000220 = 0); NONFAILING(*(uint32_t*)0x200000000228 = 0); NONFAILING(*(uint32_t*)0x20000000022c = 8); NONFAILING(memset((void*)0x200000000230, 0, 16)); NONFAILING(*(uint32_t*)0x200000000240 = 0); NONFAILING(*(uint32_t*)0x200000000244 = 0); NONFAILING(*(uint32_t*)0x200000000248 = -1); NONFAILING(*(uint32_t*)0x20000000024c = 8); NONFAILING(*(uint64_t*)0x200000000250 = 0); NONFAILING(*(uint32_t*)0x200000000258 = 0); NONFAILING(*(uint32_t*)0x20000000025c = 0x10); NONFAILING(*(uint64_t*)0x200000000260 = 0); NONFAILING(*(uint32_t*)0x200000000268 = 0); NONFAILING(*(uint32_t*)0x20000000026c = 0); NONFAILING(*(uint32_t*)0x200000000270 = 0); NONFAILING(*(uint32_t*)0x200000000274 = 0); NONFAILING(*(uint64_t*)0x200000000278 = 0); NONFAILING(*(uint64_t*)0x200000000280 = 0); NONFAILING(*(uint32_t*)0x200000000288 = 0x10); NONFAILING(*(uint32_t*)0x20000000028c = 0); NONFAILING(*(uint32_t*)0x200000000290 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000200ul, /*size=*/0x94ul); // syz_io_uring_setup arguments: [ // entries: int32 = 0x10d5 (4 bytes) // params: ptr[inout, io_uring_params] { // io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x758e (4 bytes) // flags: io_uring_setup_flags = 0x80 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x34d (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: array[int32] { // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // } // cq_off: array[int32] { // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // } // } // } // ring_ptr: ptr[out, ring_ptr] { // ring_ptr (resource) // } // sqes_ptr: ptr[out, sqes_ptr] { // sqes_ptr (resource) // } // ] // returns fd_io_uring NONFAILING(*(uint32_t*)0x200000000484 = 0x758e); NONFAILING(*(uint32_t*)0x200000000488 = 0x80); NONFAILING(*(uint32_t*)0x20000000048c = 0); NONFAILING(*(uint32_t*)0x200000000490 = 0x34d); NONFAILING(*(uint32_t*)0x200000000498 = -1); NONFAILING(memset((void*)0x20000000049c, 0, 12)); res = -1; NONFAILING(res = syz_io_uring_setup( /*entries=*/0x10d5, /*params=*/0x200000000480, /*ring_ptr=*/0x2000000000c0, /*sqes_ptr=*/0x200000000080)); if (res != -1) { r[2] = res; NONFAILING(r[3] = *(uint64_t*)0x2000000000c0); NONFAILING(r[4] = *(uint64_t*)0x200000000080); } // syz_memcpy_off$IO_URING_METADATA_GENERIC arguments: [ // ring_ptr: ring_ptr (resource) // off: io_uring_offsets = 0x4 (8 bytes) // src: ptr[in, int32] { // int32 = 0xfffffffc (4 bytes) // } // src_off: const = 0x0 (8 bytes) // nbytes: const = 0x4 (8 bytes) // ] NONFAILING(*(uint32_t*)0x200000000180 = 0xfffffffc); NONFAILING(syz_memcpy_off(/*ring_ptr=*/r[3], /*off=*/4, /*src=*/0x200000000180, /*src_off=*/0, /*nbytes=*/4)); // setsockopt$SO_ATTACH_FILTER arguments: [ // fd: sock (resource) // level: const = 0x1 (4 bytes) // optname: const = 0x1a (4 bytes) // optval: 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 = 0x32 (2 bytes) // jt: int8 = 0x0 (1 bytes) // jf: int8 = 0x0 (1 bytes) // k: int32 = 0x4 (4 bytes) // } // } // } // } // } // optlen: len = 0x10 (8 bytes) // ] NONFAILING(*(uint16_t*)0x2000000002c0 = 1); NONFAILING(*(uint64_t*)0x2000000002c8 = 0x200000000200); NONFAILING(*(uint16_t*)0x200000000200 = 0x32); NONFAILING(*(uint8_t*)0x200000000202 = 0); NONFAILING(*(uint8_t*)0x200000000203 = 0); NONFAILING(*(uint32_t*)0x200000000204 = 4); syscall(__NR_setsockopt, /*fd=*/(intptr_t)-1, /*level=*/1, /*optname=*/0x1a, /*optval=*/0x2000000002c0ul, /*optlen=*/0x10ul); // mprotect arguments: [ // addr: VMA[0x800000] // len: len = 0x800000 (8 bytes) // prot: mmap_prot = 0x5 (8 bytes) // ] syscall(__NR_mprotect, /*addr=*/0x200000000000ul, /*len=*/0x800000ul, /*prot=PROT_READ|PROT_EXEC*/ 5ul); // syz_io_uring_submit arguments: [ // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // sqe: ptr[in, io_uring_sqe_u] { // union io_uring_sqe_u { // IORING_OP_LINK_TIMEOUT: io_uring_sqe[IORING_OP_LINK_TIMEOUT, // const[0, int16], const[0, int32], const[0, int64], ptr[in, // timespec], const[1, int32], flags[io_uring_timeout_flags, int32], // sqe_user_data_not_openat, personality_only_misc] { // opcode: const = 0xf (1 bytes) // flags: iosqe_flags = 0x1 (1 bytes) // ioprio: const = 0x0 (2 bytes) // fd: const = 0x0 (4 bytes) // off: const = 0x0 (8 bytes) // addr: nil // len: const = 0x1 (4 bytes) // misc_flags: io_uring_timeout_flags = 0x8 (4 bytes) // user_data: sqe_user_data_not_openat = 0x0 (8 bytes) // misc: personality_only_misc { // buf_index_unused: const = 0x0 (2 bytes) // ioring_personality_id: ioring_personality_id (resource) // pad_unused: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00} (length 0x14) // } // } // } // } // ] NONFAILING(*(uint8_t*)0x200000000200 = 0xf); NONFAILING(*(uint8_t*)0x200000000201 = 1); NONFAILING(*(uint16_t*)0x200000000202 = 0); NONFAILING(*(uint32_t*)0x200000000204 = 0); NONFAILING(*(uint64_t*)0x200000000208 = 0); NONFAILING(*(uint64_t*)0x200000000210 = 0); NONFAILING(*(uint32_t*)0x200000000218 = 1); NONFAILING(*(uint32_t*)0x20000000021c = 8); NONFAILING(*(uint64_t*)0x200000000220 = 0); NONFAILING(*(uint16_t*)0x200000000228 = 0); NONFAILING(*(uint16_t*)0x20000000022a = 0); NONFAILING(memset((void*)0x20000000022c, 0, 20)); NONFAILING(syz_io_uring_submit(/*ring_ptr=*/r[3], /*sqes_ptr=*/r[4], /*sqe=*/0x200000000200)); // io_uring_enter arguments: [ // fd: fd_io_uring (resource) // to_submit: int32 = 0x47bc (4 bytes) // min_complete: int32 = 0x0 (4 bytes) // flags: io_uring_enter_flags = 0x0 (8 bytes) // sigmask: nil // size: len = 0x0 (8 bytes) // ] syscall(__NR_io_uring_enter, /*fd=*/r[2], /*to_submit=*/0x47bc, /*min_complete=*/0, /*flags=*/0ul, /*sigmask=*/0ul, /*size=*/0ul); // bind$ax25 arguments: [ // fd: sock_ax25 (resource) // addr: ptr[in, full_sockaddr_ax25] { // full_sockaddr_ax25 { // fsa_ax25: sockaddr_ax25 { // sax25_family: const = 0x3 (2 bytes) // sax25_call: union ax25_address { // rose: rose_address_dev { // b0: const = 0xbb (1 bytes) // b1: const = 0xbb (1 bytes) // b2: const = 0xbb (1 bytes) // b3: const = 0x1 (1 bytes) // b4: proc = 0x0 (1 bytes) // } // } // pad = 0x0 (3 bytes) // sax25_ndigis: int32 = 0x1 (4 bytes) // } // fsa_digipeater: array[ax25_address] { // union ax25_address { // bcast: ax25_address_bcast { // b0: const = 0xa2 (1 bytes) // b1: const = 0xa6 (1 bytes) // b2: const = 0xa8 (1 bytes) // b3: const = 0x40 (1 bytes) // b4: const = 0x40 (1 bytes) // b5: const = 0x40 (1 bytes) // b6: const = 0x0 (1 bytes) // } // } // union ax25_address { // rose: rose_address_dev { // b0: const = 0xbb (1 bytes) // b1: const = 0xbb (1 bytes) // b2: const = 0xbb (1 bytes) // b3: const = 0x1 (1 bytes) // b4: proc = 0x0 (1 bytes) // } // } // union ax25_address { // default: ax25_address_default { // b0: const = 0x98 (1 bytes) // b1: const = 0x92 (1 bytes) // b2: const = 0x9c (1 bytes) // b3: const = 0xaa (1 bytes) // b4: const = 0xb0 (1 bytes) // b5: const = 0x40 (1 bytes) // b6: const = 0x2 (1 bytes) // } // } // union ax25_address { // rose: rose_address_dev { // b0: const = 0xbb (1 bytes) // b1: const = 0xbb (1 bytes) // b2: const = 0xbb (1 bytes) // b3: const = 0x1 (1 bytes) // b4: proc = 0x0 (1 bytes) // } // } // union ax25_address { // netrom: address_netrom_dev { // b0: const = 0xbb (1 bytes) // b1: const = 0xbb (1 bytes) // b2: const = 0xbb (1 bytes) // b3: const = 0xbb (1 bytes) // b4: const = 0xbb (1 bytes) // b5: const = 0x0 (1 bytes) // b6: proc = 0x0 (1 bytes) // } // } // union ax25_address { // rose: rose_address_dev { // b0: const = 0xbb (1 bytes) // b1: const = 0xbb (1 bytes) // b2: const = 0xbb (1 bytes) // b3: const = 0x1 (1 bytes) // b4: proc = 0x0 (1 bytes) // } // } // union ax25_address { // remote: ax25_address_remote { // b0: const = 0xcc (1 bytes) // b1: const = 0xcc (1 bytes) // b2: const = 0xcc (1 bytes) // b3: const = 0xcc (1 bytes) // b4: const = 0xcc (1 bytes) // b5: const = 0xcc (1 bytes) // b6: proc = 0x2 (1 bytes) // } // } // union ax25_address { // default: ax25_address_default { // b0: const = 0x98 (1 bytes) // b1: const = 0x92 (1 bytes) // b2: const = 0x9c (1 bytes) // b3: const = 0xaa (1 bytes) // b4: const = 0xb0 (1 bytes) // b5: const = 0x40 (1 bytes) // b6: const = 0x2 (1 bytes) // } // } // } // } // } // addrlen: len = 0x48 (8 bytes) // ] NONFAILING(*(uint16_t*)0x200000000540 = 3); NONFAILING(*(uint8_t*)0x200000000542 = 0xbb); NONFAILING(*(uint8_t*)0x200000000543 = 0xbb); NONFAILING(*(uint8_t*)0x200000000544 = 0xbb); NONFAILING(*(uint8_t*)0x200000000545 = 1); NONFAILING(*(uint8_t*)0x200000000546 = 0); NONFAILING(*(uint32_t*)0x20000000054c = 1); NONFAILING(*(uint8_t*)0x200000000550 = 0xa2); NONFAILING(*(uint8_t*)0x200000000551 = 0xa6); NONFAILING(*(uint8_t*)0x200000000552 = 0xa8); NONFAILING(*(uint8_t*)0x200000000553 = 0x40); NONFAILING(*(uint8_t*)0x200000000554 = 0x40); NONFAILING(*(uint8_t*)0x200000000555 = 0x40); NONFAILING(*(uint8_t*)0x200000000556 = 0); NONFAILING(*(uint8_t*)0x200000000557 = 0xbb); NONFAILING(*(uint8_t*)0x200000000558 = 0xbb); NONFAILING(*(uint8_t*)0x200000000559 = 0xbb); NONFAILING(*(uint8_t*)0x20000000055a = 1); NONFAILING(*(uint8_t*)0x20000000055b = 0); NONFAILING(*(uint8_t*)0x20000000055e = 0x98); NONFAILING(*(uint8_t*)0x20000000055f = 0x92); NONFAILING(*(uint8_t*)0x200000000560 = 0x9c); NONFAILING(*(uint8_t*)0x200000000561 = 0xaa); NONFAILING(*(uint8_t*)0x200000000562 = 0xb0); NONFAILING(*(uint8_t*)0x200000000563 = 0x40); NONFAILING(*(uint8_t*)0x200000000564 = 2); NONFAILING(*(uint8_t*)0x200000000565 = 0xbb); NONFAILING(*(uint8_t*)0x200000000566 = 0xbb); NONFAILING(*(uint8_t*)0x200000000567 = 0xbb); NONFAILING(*(uint8_t*)0x200000000568 = 1); NONFAILING(*(uint8_t*)0x200000000569 = 0); NONFAILING(*(uint8_t*)0x20000000056c = 0xbb); NONFAILING(*(uint8_t*)0x20000000056d = 0xbb); NONFAILING(*(uint8_t*)0x20000000056e = 0xbb); NONFAILING(*(uint8_t*)0x20000000056f = 0xbb); NONFAILING(*(uint8_t*)0x200000000570 = 0xbb); NONFAILING(*(uint8_t*)0x200000000571 = 0); NONFAILING(*(uint8_t*)0x200000000572 = 0); NONFAILING(*(uint8_t*)0x200000000573 = 0xbb); NONFAILING(*(uint8_t*)0x200000000574 = 0xbb); NONFAILING(*(uint8_t*)0x200000000575 = 0xbb); NONFAILING(*(uint8_t*)0x200000000576 = 1); NONFAILING(*(uint8_t*)0x200000000577 = 0); NONFAILING(*(uint8_t*)0x20000000057a = 0xcc); NONFAILING(*(uint8_t*)0x20000000057b = 0xcc); NONFAILING(*(uint8_t*)0x20000000057c = 0xcc); NONFAILING(*(uint8_t*)0x20000000057d = 0xcc); NONFAILING(*(uint8_t*)0x20000000057e = 0xcc); NONFAILING(*(uint8_t*)0x20000000057f = 0xcc); NONFAILING(*(uint8_t*)0x200000000580 = 2); NONFAILING(*(uint8_t*)0x200000000581 = 0x98); NONFAILING(*(uint8_t*)0x200000000582 = 0x92); NONFAILING(*(uint8_t*)0x200000000583 = 0x9c); NONFAILING(*(uint8_t*)0x200000000584 = 0xaa); NONFAILING(*(uint8_t*)0x200000000585 = 0xb0); NONFAILING(*(uint8_t*)0x200000000586 = 0x40); NONFAILING(*(uint8_t*)0x200000000587 = 2); syscall(__NR_bind, /*fd=*/(intptr_t)-1, /*addr=*/0x200000000540ul, /*addrlen=*/0x48ul); // close arguments: [ // fd: fd (resource) // ] syscall(__NR_close, /*fd=*/(intptr_t)-1); // ioctl$sock_SIOCGIFINDEX arguments: [ // fd: sock (resource) // cmd: const = 0x8933 (4 bytes) // arg: ptr[out, ifreq_dev_t[devnames, ifindex]] { // ifreq_dev_t[devnames, ifindex] { // ifr_ifrn: buffer: {62 72 69 64 67 65 30 00 00 00 00 00 00 00 00 00} // (length 0x10) elem: ifindex (resource) pad = 0x0 (20 bytes) // } // } // ] NONFAILING(memcpy((void*)0x2000000000c0, "bridge0\000\000\000\000\000\000\000\000\000", 16)); syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x8933, /*arg=*/0x2000000000c0ul); // mprotect arguments: [ // addr: VMA[0x1000] // len: len = 0x1000 (8 bytes) // prot: mmap_prot = 0x0 (8 bytes) // ] syscall(__NR_mprotect, /*addr=*/0x200000ffd000ul, /*len=*/0x1000ul, /*prot=*/0ul); // mq_notify arguments: [ // mqd: fd_mq (resource) // notif: ptr[in, sigevent] { // sigevent { // val: const = 0x110c230000 (8 bytes) // signo: int32 = 0x803 (4 bytes) // notify: sigev_notify = 0x2 (4 bytes) // u: union sigevent_u { // tid: pid (resource) // } // pad = 0x0 (32 bytes) // } // } // ] NONFAILING(*(uint64_t*)0x200000000000 = 0x110c230000); NONFAILING(*(uint32_t*)0x200000000008 = 0x803); NONFAILING(*(uint32_t*)0x20000000000c = 2); NONFAILING(*(uint32_t*)0x200000000010 = 0); syscall(__NR_mq_notify, /*mqd=*/(intptr_t)-1, /*notif=*/0x200000000000ul); // 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 = 0x4008011 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x4000800 (8 bytes) // ] NONFAILING(*(uint64_t*)0x200000000000 = 0); NONFAILING(*(uint32_t*)0x200000000008 = 0); NONFAILING(*(uint64_t*)0x200000000010 = 0); NONFAILING(*(uint64_t*)0x200000000018 = 1); NONFAILING(*(uint64_t*)0x200000000020 = 0); NONFAILING(*(uint64_t*)0x200000000028 = 0); NONFAILING(*(uint32_t*)0x200000000030 = 0x4008011); syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000000000ul, /*f=MSG_ZEROCOPY|MSG_CONFIRM*/ 0x4000800ul); // syz_init_net_socket$bt_hci arguments: [ // fam: const = 0x1f (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x1 (8 bytes) // ] // returns sock_bt_hci NONFAILING(syz_init_net_socket(/*fam=*/0x1f, /*type=*/3, /*proto=*/1)); // syz_init_net_socket$bt_l2cap arguments: [ // fam: const = 0x1f (8 bytes) // type: bt_l2cap_type = 0x5 (8 bytes) // proto: const = 0x0 (8 bytes) // ] // returns sock_bt_l2cap res = -1; NONFAILING(res = syz_init_net_socket(/*fam=*/0x1f, /*type=SOCK_SEQPACKET*/ 5, /*proto=*/0)); if (res != -1) r[5] = res; // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: nil // size: len = 0x0 (8 bytes) // ] // returns fd_bpf_prog syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0ul, /*size=*/0ul); // modify_ldt$write arguments: [ // func: const = 0x1 (8 bytes) // buf: ptr[in, user_desc] { // user_desc { // entry_number: int32 = 0x23 (4 bytes) // base_addr: user_desc_bases = 0x1800 (4 bytes) // limit: user_desc_limits = 0x400 (4 bytes) // seg_32bit: int32 = 0x0 (0 bytes) // contents: int32 = 0x0 (0 bytes) // read_exec_only: int32 = 0x0 (0 bytes) // limit_in_pages: int32 = 0x0 (0 bytes) // seg_not_present: int32 = 0x0 (0 bytes) // useable: int32 = 0x0 (0 bytes) // lm: int32 = 0x0 (1 bytes) // pad = 0x0 (3 bytes) // } // } // len: len = 0x10 (8 bytes) // ] NONFAILING(*(uint32_t*)0x2000000003c0 = 0x23); NONFAILING(*(uint32_t*)0x2000000003c4 = 0x1800); NONFAILING(*(uint32_t*)0x2000000003c8 = 0x400); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 0, 1)); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 1, 2)); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 4, 1)); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 5, 1)); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 6, 1)); NONFAILING(STORE_BY_BITMASK(uint32_t, , 0x2000000003cc, 0, 7, 1)); syscall(__NR_modify_ldt, /*func=*/1ul, /*buf=*/0x2000000003c0ul, /*len=*/0x10ul); // bpf$BPF_PROG_WITH_BTFID_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_with_btfid] { // union bpf_prog_with_btfid { // bpf_ext: bpf_prog_t[const[BPF_PROG_TYPE_EXT, int32], const[0, // int32], int32[0:BTF_ID_MAX], fd_bpf_prog[opt]] { // type: const = 0x1c (4 bytes) // ninsn: bytesize8 = 0x0 (4 bytes) // insns: nil // license: nil // loglev: int32 = 0xc (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x41000 (4 bytes) // flags: bpf_prog_load_flags = 0x20 (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: const = 0x0 (4 bytes) // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x8 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x10 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: int32 = 0x1f075 (4 bytes) // 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 = 0x10000 (4 bytes) // prog_token_fd: union _bpf_prog_t[const[BPF_PROG_TYPE_EXT, int32], // const[0, int32], int32[0:BTF_ID_MAX], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[const[BPF_PROG_TYPE_EXT, int32], const[0, // int32], int32[0:BTF_ID_MAX], fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog_with_btfid NONFAILING(*(uint32_t*)0x200000000400 = 0x1c); NONFAILING(*(uint32_t*)0x200000000404 = 0); NONFAILING(*(uint64_t*)0x200000000408 = 0); NONFAILING(*(uint64_t*)0x200000000410 = 0); NONFAILING(*(uint32_t*)0x200000000418 = 0xc); NONFAILING(*(uint32_t*)0x20000000041c = 0); NONFAILING(*(uint64_t*)0x200000000420 = 0); NONFAILING(*(uint32_t*)0x200000000428 = 0x41000); NONFAILING(*(uint32_t*)0x20000000042c = 0x20); NONFAILING(memset((void*)0x200000000430, 0, 16)); NONFAILING(*(uint32_t*)0x200000000440 = 0); NONFAILING(*(uint32_t*)0x200000000444 = 0); NONFAILING(*(uint32_t*)0x200000000448 = -1); NONFAILING(*(uint32_t*)0x20000000044c = 8); NONFAILING(*(uint64_t*)0x200000000450 = 0); NONFAILING(*(uint32_t*)0x200000000458 = 0); NONFAILING(*(uint32_t*)0x20000000045c = 0x10); NONFAILING(*(uint64_t*)0x200000000460 = 0); NONFAILING(*(uint32_t*)0x200000000468 = 0); NONFAILING(*(uint32_t*)0x20000000046c = 0x1f075); NONFAILING(*(uint32_t*)0x200000000470 = -1); NONFAILING(*(uint32_t*)0x200000000474 = 0); NONFAILING(*(uint64_t*)0x200000000478 = 0); NONFAILING(*(uint64_t*)0x200000000480 = 0); NONFAILING(*(uint32_t*)0x200000000488 = 0x10); NONFAILING(*(uint32_t*)0x20000000048c = 0x10000); NONFAILING(*(uint32_t*)0x200000000490 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000400ul, /*size=*/0x94ul); // syz_clone arguments: [ // flags: clone_flags = 0x0 (8 bytes) // stack: nil // stack_len: bytesize = 0x0 (8 bytes) // parentid: nil // childtid: nil // tls: nil // ] // returns pid res = -1; NONFAILING(res = syz_clone(/*flags=*/0, /*stack=*/0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0)); if (res != -1) r[6] = res; // ptrace arguments: [ // req: ptrace_req = 0x10 (8 bytes) // pid: pid (resource) // ] syscall(__NR_ptrace, /*req=PTRACE_ATTACH*/ 0x10ul, /*pid=*/r[6], 0, 0); // ptrace$setregs arguments: [ // req: ptrace_req_setregs = 0xd (8 bytes) // pid: pid (resource) // ignored: intptr = 0x0 (8 bytes) // data: nil // ] syscall(__NR_ptrace, /*req=PTRACE_SETREGS*/ 0xdul, /*pid=*/r[6], /*ignored=*/0ul, /*data=*/0ul); // bind$bt_l2cap arguments: [ // fd: sock_bt_l2cap (resource) // addr: ptr[in, sockaddr_l2] { // sockaddr_l2 { // l2_family: const = 0x1f (2 bytes) // l2_psm: int16 = 0x1 (2 bytes) // l2_bdaddr: union bdaddr_t { // none: buffer: {ff ff ff ff ff ff} (length 0x6) // } // l2_cid: int16 = 0x0 (2 bytes) // l2_bdaddr_type: bdaddr_type = 0x1 (1 bytes) // pad = 0x0 (1 bytes) // } // } // addrlen: len = 0xe (8 bytes) // ] NONFAILING(*(uint16_t*)0x200000000340 = 0x1f); NONFAILING(*(uint16_t*)0x200000000342 = 1); NONFAILING(memset((void*)0x200000000344, 255, 6)); NONFAILING(*(uint16_t*)0x20000000034a = 0); NONFAILING(*(uint8_t*)0x20000000034c = 1); syscall(__NR_bind, /*fd=*/r[5], /*addr=*/0x200000000340ul, /*addrlen=*/0xeul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*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=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; install_segv_handler(); loop(); return 0; }