// https://syzkaller.appspot.com/bug?id=8c0173f9126eb1d9499cba81e26aa7cf87d9b64f // 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 #ifndef __NR_bpf #define __NR_bpf 357 #endif #ifndef __NR_connect #define __NR_connect 362 #endif #ifndef __NR_dup #define __NR_dup 41 #endif #ifndef __NR_ioctl #define __NR_ioctl 54 #endif #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_openat #define __NR_openat 295 #endif #ifndef __NR_recvmmsg #define __NR_recvmmsg 337 #endif #ifndef __NR_sendmmsg #define __NR_sendmmsg 345 #endif #ifndef __NR_sendmsg #define __NR_sendmsg 370 #endif #ifndef __NR_socket #define __NR_socket 359 #endif #ifndef __NR_socketpair #define __NR_socketpair 360 #endif #ifndef __NR_write #define __NR_write 4 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 static unsigned long long procid; 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; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } 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; } #define SIZEOF_IO_URING_SQE 64 #define SIZEOF_IO_URING_CQE 16 #define IORING_SETUP_SQE128 (1U << 10) #define IORING_SETUP_CQE32 (1U << 11) 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 user_addr; }; struct io_cqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t overflow; uint32_t cqes; uint32_t flags; uint32_t resv1; uint64_t user_addr; }; 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; }; static long io_uring_sqe_size(struct io_uring_params* params) { return SIZEOF_IO_URING_SQE << !!(params->flags & IORING_SETUP_SQE128); } static long syz_io_uring_submit(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { struct io_uring_params* params = (struct io_uring_params*)a0; char* ring_ptr = (char*)a1; char* sqes_ptr = (char*)a2; char* sqe = (char*)a3; uint32_t sq_ring_mask = *(uint32_t*)(ring_ptr + params->sq_off.ring_mask); uint32_t* sq_tail_ptr = (uint32_t*)(ring_ptr + params->sq_off.tail); uint32_t sq_tail = *sq_tail_ptr & sq_ring_mask; uint32_t sqe_size = io_uring_sqe_size(params); char* sqe_dest = sqes_ptr + sq_tail * sqe_size; memcpy(sqe_dest, sqe, sqe_size); uint32_t sq_tail_next = *sq_tail_ptr + 1; __atomic_store_n(sq_tail_ptr, sq_tail_next, __ATOMIC_RELEASE); return 0; } #define UBLK_F_USER_COPY (1UL << 7) #define UBLK_IO_RES_OK 0 #define UBLK_IO_RES_NEED_GET_DATA 1 #define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21 #define UBLK_IO_NEED_GET_DATA 0x22 #define UBLK_U_IO_COMMIT_AND_FETCH_REQ \ _IOWR('u', UBLK_IO_COMMIT_AND_FETCH_REQ, struct ublksrv_io_cmd) #define UBLK_U_IO_NEED_GET_DATA \ _IOWR('u', UBLK_IO_NEED_GET_DATA, struct ublksrv_io_cmd) struct ublksrv_ctrl_cmd { __u32 dev_id; __u16 queue_id; __u16 len; __u64 addr; __u64 data[1]; __u16 dev_path_len; __u16 pad; __u32 reserved; }; struct ublksrv_ctrl_dev_info { __u16 nr_hw_queues; __u16 queue_depth; __u16 state; __u16 pad0; __u32 max_io_buf_bytes; __u32 dev_id; __s32 ublksrv_pid; __u32 pad1; __u64 flags; __u64 ublksrv_flags; __u32 owner_uid; __u32 owner_gid; __u64 reserved1; __u64 reserved2; }; struct ublksrv_io_desc { __u32 op_flags; union { __u32 nr_sectors; __u32 nr_zones; }; __u64 start_sector; __u64 addr; }; struct ublksrv_io_cmd { __u16 q_id; __u16 tag; __s32 result; union { __u64 addr; __u64 zone_append_lba; }; }; struct io_uring_sqe { __u8 opcode; __u8 flags; __u16 ioprio; __s32 fd; union { __u64 off; __u64 addr2; struct { __u32 cmd_op; __u32 __pad1; }; }; union { __u64 addr; __u64 splice_off_in; struct { __u32 level; __u32 optname; }; }; __u32 len; union { __kernel_rwf_t rw_flags; __u32 fsync_flags; __u16 poll_events; __u32 poll32_events; __u32 sync_range_flags; __u32 msg_flags; __u32 timeout_flags; __u32 accept_flags; __u32 cancel_flags; __u32 open_flags; __u32 statx_flags; __u32 fadvise_advice; __u32 splice_flags; __u32 rename_flags; __u32 unlink_flags; __u32 hardlink_flags; __u32 xattr_flags; __u32 msg_ring_flags; __u32 uring_cmd_flags; __u32 waitid_flags; __u32 futex_flags; __u32 install_fd_flags; __u32 nop_flags; __u32 pipe_flags; }; __u64 user_data; union { __u16 buf_index; __u16 buf_group; } __attribute__((packed)); __u16 personality; union { __s32 splice_fd_in; __u32 file_index; __u32 zcrx_ifq_idx; __u32 optlen; struct { __u16 addr_len; __u16 __pad3[1]; }; }; union { struct { __u64 addr3; __u64 __pad2[1]; }; struct { __u64 attr_ptr; __u64 attr_type_mask; }; __u64 optval; __u8 cmd[0]; }; }; static long syz_ublk_add_dev(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4, volatile long a5) { __u32 ring_fd = (__u32)a0; struct io_uring_params* params = (struct io_uring_params*)a1; char* ring_ptr = (char*)a2; char* sqes_ptr = (char*)a3; struct io_uring_sqe* sqe = (struct io_uring_sqe*)a4; void** dev_info_ptr_out = (void**)a5; struct ublksrv_ctrl_cmd* cmd = (struct ublksrv_ctrl_cmd*)(sqe->cmd); struct ublksrv_ctrl_dev_info* dev_info = (struct ublksrv_ctrl_dev_info*)(unsigned long)(cmd->addr); dev_info->flags |= UBLK_F_USER_COPY; int ret = syz_io_uring_submit((long)params, (long)ring_ptr, (long)sqes_ptr, (long)sqe); if (ret < 0) return (long)ret; syscall(__NR_io_uring_enter, ring_fd, 1, 1, 1, NULL, _NSIG / 8); *dev_info_ptr_out = (void*)dev_info; return dev_info->dev_id; } 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"); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 15; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } 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[5] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: // socket$kcm arguments: [ // domain: const = 0xa (4 bytes) // type: kcm_socket_type = 0x1 (4 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_kcm syscall(__NR_socket, /*domain=*/0xa, /*type=*/1, /*proto=*/0); break; case 1: // socketpair$unix arguments: [ // domain: const = 0x1 (4 bytes) // type: unix_socket_type = 0x3 (4 bytes) // proto: const = 0x0 (4 bytes) // fds: ptr[out, unix_pair] { // unix_pair { // fd0: sock_unix (resource) // fd1: sock_unix (resource) // } // } // ] res = syscall(__NR_socketpair, /*domain=*/1, /*type=SOCK_DGRAM|SOCK_STREAM*/ 3, /*proto=*/0, /*fds=*/0x80000080); if (res != -1) { NONFAILING(r[0] = *(uint32_t*)0x80000080); NONFAILING(r[1] = *(uint32_t*)0x80000084); } break; case 2: // connect$unix arguments: [ // fd: sock_unix (resource) // addr: ptr[in, sockaddr_un] { // union sockaddr_un { // abs: sockaddr_un_abstract { // family: unix_socket_family = 0x0 (2 bytes) // ind: const = 0x0 (1 bytes) // pad = 0x0 (1 bytes) // id: int32 = 0x0 (4 bytes) // } // } // } // addrlen: len = 0x6e (4 bytes) // ] NONFAILING(*(uint16_t*)0x8057eff8 = 0); NONFAILING(*(uint8_t*)0x8057effa = 0); NONFAILING(*(uint32_t*)0x8057effc = 0); syscall(__NR_connect, /*fd=*/(intptr_t)r[0], /*addr=*/0x8057eff8, /*addrlen=*/0x6e); break; case 3: // socket$nl_netfilter arguments: [ // domain: const = 0x10 (4 bytes) // type: const = 0x3 (4 bytes) // proto: const = 0xc (4 bytes) // ] // returns sock_nl_netfilter res = syscall(__NR_socket, /*domain=*/0x10, /*type=*/3, /*proto=*/0xc); if (res != -1) r[2] = res; break; case 4: // sendmsg$NFT_BATCH arguments: [ // fd: sock_nl_netfilter (resource) // msg: nil // f: send_flags = 0x0 (4 bytes) // ] syscall(__NR_sendmsg, /*fd=*/(intptr_t)r[2], /*msg=*/0, /*f=*/0); break; case 5: // sendmmsg$unix arguments: [ // fd: sock_unix (resource) // mmsg: ptr[in, array[send_mmsghdr_un]] { // array[send_mmsghdr_un] { // } // } // vlen: len = 0x318 (4 bytes) // f: send_flags = 0x0 (4 bytes) // ] syscall(__NR_sendmmsg, /*fd=*/(intptr_t)r[1], /*mmsg=*/0x800bd000, /*vlen=*/0x318, /*f=*/0); break; case 6: // openat$nvme_fabrics arguments: [ // fd: const = 0xffffffffffffff9c (4 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6e 76 6d 65 2d 66 61 62 72 69 63 73 00} // (length 0x12) // } // flags: open_flags = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd NONFAILING(memcpy((void*)0x80000100, "/dev/nvme-fabrics\000", 18)); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x80000100, /*flags=O_RDWR*/ 2, /*mode=*/0); if (res != -1) r[3] = res; break; case 7: // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {74 72 61 6e 73 70 6f 72 74 3d 74 63 70 2c 74 72 61 64 64 72 // 3d 31 32 37 2e 30 2e 30 2e 31 2c 74 72 73 76 63 69 64 3d 34 34 32 30 // 2c 6e 71 6e 3d 74} (length 0x31) // } // count: len = 0x31 (4 bytes) // ] NONFAILING(memcpy((void*)0x80000200, "transport=tcp,traddr=127.0.0.1,trsvcid=4420,nqn=t", 49)); syscall(__NR_write, /*fd=*/(intptr_t)r[3], /*buf=*/0x80000200, /*count=*/0x31); break; case 8: // ioctl$AUTOFS_DEV_IOCTL_VERSION arguments: [ // fd: fd_autofs (resource) // cmd: const = 0xc0189371 (4 bytes) // arg: ptr[inout, autofs_dev_ioctl[void]] { // autofs_dev_ioctl[void] { // base: autofs_dev_ioctl_base[void] { // ver_major: const = 0x1 (4 bytes) // ver_minor: const = 0x1 (4 bytes) // size: len = 0x18 (4 bytes) // ioctlfd: fd (resource) // content: buffer: {} (length 0x0) // pad = 0x0 (8 bytes) // } // path: buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // } // ] NONFAILING(*(uint32_t*)0x80000140 = 1); NONFAILING(*(uint32_t*)0x80000144 = 1); NONFAILING(*(uint32_t*)0x80000148 = 0x18); NONFAILING(*(uint32_t*)0x8000014c = r[0]); NONFAILING(memcpy((void*)0x80000158, "./file0\000", 8)); syscall(__NR_ioctl, /*fd=*/(intptr_t)r[3], /*cmd=*/0xc0189371, /*arg=*/0x80000140); break; case 9: // syz_ublk_add_dev arguments: [ // fd_io_uring: fd_io_uring (resource) // ring_params_ptr: ring_params_ptr (resource) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // sqe: nil // dev_info_ptr: ptr[out, dev_info_ptr] { // dev_info_ptr (resource) // } // ] // returns ublk_dev_id NONFAILING(syz_ublk_add_dev(/*fd_io_uring=*/-1, /*ring_params_ptr=*/0, /*ring_ptr=*/0, /*sqes_ptr=*/0, /*sqe=*/0, /*dev_info_ptr=*/0x80000480)); break; case 10: // dup arguments: [ // oldfd: fd (resource) // ] // returns fd syscall(__NR_dup, /*oldfd=*/(intptr_t)-1); break; case 11: // bpf$PROG_LOAD_XDP arguments: [ // cmd: const = 0x5 (4 bytes) // arg: ptr[in, bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], // const[BPF_XDP, int32], const[0, int32], const[0, int32]]] { // bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], const[BPF_XDP, int32], // const[0, int32], const[0, int32]] { // type: const = 0x6 (4 bytes) // ninsn: bytesize8 = 0x3 (4 bytes) // insns: nil // license: nil // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0xffffffffffffff4f (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x7 (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 = 0x25 (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[const[BPF_PROG_TYPE_XDP, int32], // const[BPF_XDP, int32], const[0, int32], const[0, // int32]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], // const[BPF_XDP, int32], const[0, int32], const[0, // int32]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (4 bytes) // ] // returns fd_bpf_prog_xdp NONFAILING(*(uint32_t*)0x80000340 = 6); NONFAILING(*(uint32_t*)0x80000344 = 3); NONFAILING(*(uint64_t*)0x80000348 = 0); NONFAILING(*(uint64_t*)0x80000350 = 0); NONFAILING(*(uint32_t*)0x80000358 = 0); NONFAILING(*(uint32_t*)0x8000035c = 0xffffff4f); NONFAILING(*(uint64_t*)0x80000360 = 0); NONFAILING(*(uint32_t*)0x80000368 = 0); NONFAILING(*(uint32_t*)0x8000036c = 7); NONFAILING(memset((void*)0x80000370, 0, 16)); NONFAILING(*(uint32_t*)0x80000380 = 0); NONFAILING(*(uint32_t*)0x80000384 = 0x25); NONFAILING(*(uint32_t*)0x80000388 = -1); NONFAILING(*(uint32_t*)0x8000038c = 8); NONFAILING(*(uint64_t*)0x80000390 = 0); NONFAILING(*(uint32_t*)0x80000398 = 0); NONFAILING(*(uint32_t*)0x8000039c = 0x10); NONFAILING(*(uint64_t*)0x800003a0 = 0); NONFAILING(*(uint32_t*)0x800003a8 = 0); NONFAILING(*(uint32_t*)0x800003ac = 0); NONFAILING(*(uint32_t*)0x800003b0 = 0); NONFAILING(*(uint32_t*)0x800003b4 = 0); NONFAILING(*(uint64_t*)0x800003b8 = 0); NONFAILING(*(uint64_t*)0x800003c0 = 0); NONFAILING(*(uint32_t*)0x800003c8 = 0x10); NONFAILING(*(uint32_t*)0x800003cc = 0); NONFAILING(*(uint32_t*)0x800003d0 = 0); syscall(__NR_bpf, /*cmd=*/5, /*arg=*/0x80000340, /*size=*/0x94); break; case 12: // recvmmsg arguments: [ // fd: sock (resource) // mmsg: ptr[in, array[recv_mmsghdr]] { // array[recv_mmsghdr] { // } // } // vlen: len = 0x10106 (4 bytes) // f: recv_flags = 0x2 (4 bytes) // timeout: nil // ] syscall(__NR_recvmmsg, /*fd=*/(intptr_t)r[0], /*mmsg=*/0x800000c0, /*vlen=*/0x10106, /*f=MSG_PEEK*/ 2, /*timeout=*/0); break; case 13: // socket$kcm arguments: [ // domain: const = 0x10 (4 bytes) // type: kcm_socket_type = 0x2 (4 bytes) // proto: const = 0x4 (4 bytes) // ] // returns sock_kcm res = syscall(__NR_socket, /*domain=*/0x10, /*type=SOCK_DGRAM*/ 2, /*proto=*/4); if (res != -1) r[4] = res; break; case 14: // sendmsg$kcm arguments: [ // fd: sock_kcm (resource) // msg: ptr[in, send_msghdr] { // send_msghdr { // msg_name: nil // msg_namelen: len = 0x0 (4 bytes) // msg_iov: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {89 00 00 00 12 00 81 ae 08 06 0c dc 03 00 00 00 // 7f 03 e3 f7 00 00 00 00 6e e2 ff ca 1b 1f 33 17 00 00 04 // c0 0e 72 f7 50 37 5e d0 8a 56 33 1d bf 9e d7 81 5e 38 1a // d6 e7 47 03 3a 00 93 b8 37 dc 6c c0 1e 32 ef ae c8 c7 a6 // ec 00 12 10 00 01 40 0a 0c 0c 00 bd ad 44 6b 9b bc 7a 46 // e3 98 82 85 dc df 12 f2 13 08 f8 68 fe ce 01 95 5f ed 00 // 09 d7 8f 0a 94 7e e2 b4 9e 33 53 8a fa 8a f9 23 47 51 4f // 0b 56 a2 0f f2 7f ff} (length 0x89) // } // len: len = 0x89 (4 bytes) // } // } // } // msg_iovlen: len = 0x1 (4 bytes) // msg_control: nil // msg_controllen: bytesize = 0x0 (4 bytes) // msg_flags: const = 0x0 (4 bytes) // } // } // f: send_flags = 0x4004010 (4 bytes) // ] NONFAILING(*(uint32_t*)0x80000240 = 0); NONFAILING(*(uint32_t*)0x80000244 = 0); NONFAILING(*(uint32_t*)0x80000248 = 0x80000000); NONFAILING(*(uint32_t*)0x80000000 = 0x80000440); NONFAILING(memcpy( (void*)0x80000440, "\x89\x00\x00\x00\x12\x00\x81\xae\x08\x06\x0c\xdc\x03\x00\x00\x00\x7f" "\x03\xe3\xf7\x00\x00\x00\x00\x6e\xe2\xff\xca\x1b\x1f\x33\x17\x00\x00" "\x04\xc0\x0e\x72\xf7\x50\x37\x5e\xd0\x8a\x56\x33\x1d\xbf\x9e\xd7\x81" "\x5e\x38\x1a\xd6\xe7\x47\x03\x3a\x00\x93\xb8\x37\xdc\x6c\xc0\x1e\x32" "\xef\xae\xc8\xc7\xa6\xec\x00\x12\x10\x00\x01\x40\x0a\x0c\x0c\x00\xbd" "\xad\x44\x6b\x9b\xbc\x7a\x46\xe3\x98\x82\x85\xdc\xdf\x12\xf2\x13\x08" "\xf8\x68\xfe\xce\x01\x95\x5f\xed\x00\x09\xd7\x8f\x0a\x94\x7e\xe2\xb4" "\x9e\x33\x53\x8a\xfa\x8a\xf9\x23\x47\x51\x4f\x0b\x56\xa2\x0f\xf2\x7f" "\xff", 137)); NONFAILING(*(uint32_t*)0x80000004 = 0x89); NONFAILING(*(uint32_t*)0x8000024c = 1); NONFAILING(*(uint32_t*)0x80000250 = 0); NONFAILING(*(uint32_t*)0x80000254 = 0); NONFAILING(*(uint32_t*)0x80000258 = 0); syscall(__NR_sendmsg, /*fd=*/(intptr_t)r[4], /*msg=*/0x80000240, /*f=MSG_ZEROCOPY|MSG_PROBE|MSG_NOSIGNAL*/ 0x4004010); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x7ffff000, /*len=*/0x1000, /*prot=*/0, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32, /*fd=*/(intptr_t)-1, /*offset=*/0); syscall(__NR_mmap, /*addr=*/0x80000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32, /*fd=*/(intptr_t)-1, /*offset=*/0); syscall(__NR_mmap, /*addr=*/0x81000000, /*len=*/0x1000, /*prot=*/0, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32, /*fd=*/(intptr_t)-1, /*offset=*/0); const char* reason; (void)reason; install_segv_handler(); for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }