// https://syzkaller.appspot.com/bug?id=f21d596a159401d5485e4513c909c514be801db0 // 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_getpid #define __NR_getpid 172 #endif #ifndef __NR_io_uring_enter #define __NR_io_uring_enter 426 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_openat #define __NR_openat 56 #endif 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); } #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)))) 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 io_uring_cqe_size(struct io_uring_params* params) { return SIZEOF_IO_URING_CQE << !!(params->flags & IORING_SETUP_CQE32); } #define IORING_OFF_SQ_RING 0ULL #define IORING_OFF_SQES 0x10000000ULL static long syz_io_uring_setup(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4) { uint32_t entries = (uint32_t)a0; struct io_uring_params* setup_params = (struct io_uring_params*)a1; void** ring_params_ptr_out = (void**)a2; void** ring_ptr_out = (void**)a3; void** sqes_ptr_out = (void**)a4; uint32_t fd_io_uring = syscall(__NR_io_uring_setup, entries, setup_params); *ring_params_ptr_out = (void*)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 * io_uring_cqe_size(setup_params); 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 * io_uring_sqe_size(setup_params); *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 < setup_params->sq_entries; index++) array[index] = index; return fd_io_uring; } 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; } static long syz_ublk_setup_io_uring(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4) { struct io_uring_params* params = (struct io_uring_params*)a1; params->flags |= IORING_SETUP_SQE128 | IORING_SETUP_CQE32; return syz_io_uring_setup(a0, (long)params, a2, a3, a4); } #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; } struct ublk_queue { __u16 q_id; __u32 char_dev_fd; struct io_uring_params params; __u32 ring_fd; char* ring_ptr; char* sqes_ptr; char* io_cmd_buf; }; #define UBLK_MAX_QUEUE_DEPTH 4096 #define UBLK_QUEUES_OFFSET 0 #define round_up(x, y) (((x) + (y) - 1) / (y) * (y)) static long syz_ublk_setup_queues(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4, volatile long a5, volatile long a6) { int char_dev_fd = (int)a0; struct ublksrv_ctrl_dev_info* dev_info = (struct ublksrv_ctrl_dev_info*)a1; struct io_uring_params* params = (struct io_uring_params*)a2; struct ublk_queue* queues = (struct ublk_queue*)a3; int queues_len = (int)a4; struct io_uring_sqe* sqe = (struct io_uring_sqe*)a5; void** queues_ptr_out = (void**)a6; if (char_dev_fd < 0 || !dev_info) return -1; memset(queues, 0, sizeof(struct ublk_queue) * queues_len); int queue_depth = dev_info->queue_depth; for (int q_id = 0; q_id < dev_info->nr_hw_queues; q_id++) { struct ublk_queue* queue = &queues[q_id]; queue->q_id = q_id; queue->char_dev_fd = char_dev_fd; queue->params = *params; struct io_uring_params* temp = NULL; queue->ring_fd = syz_ublk_setup_io_uring( (long)queue_depth, (long)&queue->params, (long)&temp, (long)&queue->ring_ptr, (long)&queue->sqes_ptr); if (queue->ring_fd < 0) { return queue->ring_fd; } unsigned long cmd_buf_size = round_up(queue_depth * sizeof(struct ublksrv_io_desc), getpagesize()); unsigned long off = UBLK_QUEUES_OFFSET + q_id * round_up(UBLK_MAX_QUEUE_DEPTH * sizeof(struct ublksrv_io_desc), getpagesize()); queue->io_cmd_buf = (char*)mmap(0, cmd_buf_size, PROT_READ, MAP_SHARED | MAP_POPULATE, char_dev_fd, off); if (queue->io_cmd_buf == MAP_FAILED) { return -1; } for (int j = 0; j < queue_depth; j++) { struct ublksrv_io_cmd* cmd = (struct ublksrv_io_cmd*)(&sqe->cmd); cmd->q_id = q_id; cmd->tag = j; cmd->addr = 0; sqe->user_data = j | (sqe->cmd_op << 16); if (syz_io_uring_submit((long)&queue->params, (long)queue->ring_ptr, (long)queue->sqes_ptr, (long)sqe) < 0) { return -1; } syscall(__NR_io_uring_enter, queue->ring_fd, 1, 0, 0, NULL, _NSIG / 8); } } *queues_ptr_out = (void*)queues; return 0; } static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2 & ~O_CREAT, 0); } } 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 < 12; 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[14] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: // openat$ublk_ctrl arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 75 62 6c 6b 2d 63 6f 6e 74 72 6f 6c 00} // (length 0x12) // } // flags: const = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_ublk_ctrl memcpy((void*)0x20000000, "/dev/ublk-control\000", 18); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000000ul, /*flags=*/2, /*mode=*/0); if (res != -1) r[0] = res; break; case 1: // syz_ublk_setup_io_uring arguments: [ // entries: int32 = 0x20 (4 bytes) // params: ptr[inout, io_uring_params] { // io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x0 (4 bytes) // flags: io_uring_setup_flags = 0x0 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x0 (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) // } // } // } // ring_params_ptr: ptr[out, ring_params_ptr] { // ring_params_ptr (resource) // } // ring_ptr: ptr[out, ring_ptr] { // ring_ptr (resource) // } // sqes_ptr: ptr[out, sqes_ptr] { // sqes_ptr (resource) // } // ] // returns fd_io_uring *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x2000004c = 0; *(uint32_t*)0x20000050 = 0; *(uint32_t*)0x20000058 = -1; memset((void*)0x2000005c, 0, 12); res = -1; res = syz_ublk_setup_io_uring( /*entries=*/0x20, /*params=*/0x20000040, /*ring_params_ptr=*/0x200000c0, /*ring_ptr=*/0x20000100, /*sqes_ptr=*/0x20000140); if (res != -1) { r[1] = res; r[2] = *(uint64_t*)0x200000c0; r[3] = *(uint64_t*)0x20000100; r[4] = *(uint64_t*)0x20000140; } break; case 2: // 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: ptr[inout, io_uring_sqe_uring[fd_ublk_ctrl, // const[UBLK_U_CMD_ADD_DEV, int32], ublk_ctrl_cmd$add_dev, int64]] { // io_uring_sqe_uring[fd_ublk_ctrl, const[UBLK_U_CMD_ADD_DEV, int32], // ublk_ctrl_cmd$add_dev, int64] { // opcode: const = 0x2e (1 bytes) // flags: iosqe_flags = 0x0 (1 bytes) // ioprio: const = 0x0 (2 bytes) // fd: fd_ublk_ctrl (resource) // cmd_op: const = 0xc0207504 (4 bytes) // pad1: const = 0x0 (4 bytes) // addr: const = 0x0 (8 bytes) // len: const = 0x0 (4 bytes) // uring_flags: uring_cmd_flags = 0x0 (4 bytes) // user_data: int64 = 0x0 (8 bytes) // buf_index_unused: const = 0x0 (2 bytes) // ioring_personality_id: ioring_personality_id (resource) // pad_unused: buffer: {00 00 00 00} (length 0x4) // cmd: ublk_ctrl_cmd[const[-1, int32], len[addr, int16], ptr64[in, // ublk_ctrl_dev_info_new], const[0, int64]] { // dev_id: const = 0xffffffff (4 bytes) // queue_id: const = 0xffff (2 bytes) // len: len = 0x48 (2 bytes) // addr: ptr[in, ublk_ctrl_dev_info_new] { // union ublk_ctrl_dev_info_new { // new_dev: ublk_ctrl_dev_info[const[-1, int32]] { // nr_hw_queues: int16 = 0x1 (2 bytes) // queue_depth: int16 = 0x4 (2 bytes) // state: const = 0x0 (2 bytes) // pad0: const = 0x0 (2 bytes) // max_io_buf_bytes: const = 0x1000 (4 bytes) // dev_id: const = 0xffffffff (4 bytes) // ublk_pid: pid (resource) // pad1: const = 0x0 (4 bytes) // flags: ublk_f_flags = 0x0 (8 bytes) // ublk_flags: const = 0x0 (8 bytes) // owner_uid: const = 0x0 (4 bytes) // owner_gid: const = 0x0 (4 bytes) // reserved1: const = 0x0 (8 bytes) // reserved2: const = 0x0 (8 bytes) // } // } // } // data: const = 0x0 (8 bytes) // dev_path_len: const = 0x0 (2 bytes) // pad: const = 0x0 (2 bytes) // reserved: const = 0x0 (4 bytes) // pad2_unused: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x30) // } // } // } // dev_info_ptr: ptr[out, dev_info_ptr] { // dev_info_ptr (resource) // } // ] // returns ublk_dev_id *(uint8_t*)0x20000200 = 0x2e; *(uint8_t*)0x20000201 = 0; *(uint16_t*)0x20000202 = 0; *(uint32_t*)0x20000204 = r[0]; *(uint32_t*)0x20000208 = 0xc0207504; *(uint32_t*)0x2000020c = 0; *(uint64_t*)0x20000210 = 0; *(uint32_t*)0x20000218 = 0; *(uint32_t*)0x2000021c = 0; *(uint64_t*)0x20000220 = 0; *(uint16_t*)0x20000228 = 0; *(uint16_t*)0x2000022a = 0; memset((void*)0x2000022c, 0, 4); *(uint32_t*)0x20000230 = -1; *(uint16_t*)0x20000234 = -1; *(uint16_t*)0x20000236 = 0x48; *(uint64_t*)0x20000238 = 0x20000500; *(uint16_t*)0x20000500 = 1; *(uint16_t*)0x20000502 = 4; *(uint16_t*)0x20000504 = 0; *(uint16_t*)0x20000506 = 0; *(uint32_t*)0x20000508 = 0x1000; *(uint32_t*)0x2000050c = -1; *(uint32_t*)0x20000510 = 0; *(uint32_t*)0x20000514 = 0; *(uint64_t*)0x20000518 = 0; *(uint64_t*)0x20000520 = 0; *(uint32_t*)0x20000528 = 0; *(uint32_t*)0x2000052c = 0; *(uint64_t*)0x20000530 = 0; *(uint64_t*)0x20000538 = 0; *(uint64_t*)0x20000240 = 0; *(uint16_t*)0x20000248 = 0; *(uint16_t*)0x2000024a = 0; *(uint32_t*)0x2000024c = 0; memset((void*)0x20000250, 0, 48); res = -1; res = syz_ublk_add_dev(/*fd_io_uring=*/r[1], /*ring_params_ptr=*/r[2], /*ring_ptr=*/r[3], /*sqes_ptr=*/r[4], /*sqe=*/0x20000200, /*dev_info_ptr=*/0x20000300); if (res != -1) { r[5] = res; r[6] = *(uint64_t*)0x20000300; } break; case 3: // syz_open_dev$ublk_chdev arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 75 62 6c 6b 63 23 00} (length 0xc) // } // id: ublk_dev_id (resource) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_ublk_ch memcpy((void*)0x20002000, "/dev/ublkc#\000", 12); res = -1; res = syz_open_dev(/*dev=*/0x20002000, /*id=*/r[5], /*flags=O_RDWR*/ 2); if (res != -1) r[7] = res; break; case 4: // syz_ublk_setup_queues arguments: [ // fd_ublk_ch: fd_ublk_ch (resource) // dev_info_ptr: dev_info_ptr (resource) // params: ptr[in, io_uring_params] { // io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x0 (4 bytes) // flags: io_uring_setup_flags = 0x0 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x0 (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) // } // } // } // queues: ptr[out, array[ublk_queue]] { // array[ublk_queue] { // ublk_queue { // queue_id: int16 = 0x0 (2 bytes) // pad1: const = 0x0 (2 bytes) // fd_ublk_ch: fd_ublk_ch (resource) // params: io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x0 (4 bytes) // flags: io_uring_setup_flags = 0x0 (4 bytes) // sq_thread_cpu: int32 = 0x1 (4 bytes) // sq_thread_idle: int32 = 0x0 (4 bytes) // features: int32 = 0x0 (4 bytes) // wq_fd: fd_io_uring (resource) // resv: buffer: (DirOut) // 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) // } // } // ring_fd: fd_io_uring (resource) // pad2: const = 0x0 (4 bytes) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // io_cmd_buf: intptr = 0x0 (8 bytes) // } // ublk_queue { // queue_id: int16 = 0x0 (2 bytes) // pad1: const = 0x0 (2 bytes) // fd_ublk_ch: fd_ublk_ch (resource) // params: io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x0 (4 bytes) // flags: io_uring_setup_flags = 0x0 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x0 (4 bytes) // features: int32 = 0x0 (4 bytes) // wq_fd: fd_io_uring (resource) // resv: buffer: (DirOut) // 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) // } // } // ring_fd: fd_io_uring (resource) // pad2: const = 0x0 (4 bytes) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // io_cmd_buf: intptr = 0x0 (8 bytes) // } // ublk_queue { // queue_id: int16 = 0x0 (2 bytes) // pad1: const = 0x0 (2 bytes) // fd_ublk_ch: fd_ublk_ch (resource) // params: io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0xb026 (4 bytes) // flags: io_uring_setup_flags = 0x0 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x0 (4 bytes) // features: int32 = 0x0 (4 bytes) // wq_fd: fd_io_uring (resource) // resv: buffer: (DirOut) // 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) // } // } // ring_fd: fd_io_uring (resource) // pad2: const = 0x0 (4 bytes) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // io_cmd_buf: intptr = 0x0 (8 bytes) // } // ublk_queue { // queue_id: int16 = 0x0 (2 bytes) // pad1: const = 0x0 (2 bytes) // fd_ublk_ch: fd_ublk_ch (resource) // params: io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x0 (4 bytes) // flags: io_uring_setup_flags = 0x2000 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x0 (4 bytes) // features: int32 = 0x0 (4 bytes) // wq_fd: fd_io_uring (resource) // resv: buffer: (DirOut) // 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) // } // } // ring_fd: fd_io_uring (resource) // pad2: const = 0x0 (4 bytes) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // io_cmd_buf: intptr = 0x0 (8 bytes) // } // } // } // nr_queues: const = 0x1 (8 bytes) // sqe: ptr[inout, io_uring_sqe_uring[fd_ublk_ch, // const[UBLK_U_IO_FETCH_REQ, int32], ublk_io_cmd$fetch_req, // user_data[UBLK_U_IO_FETCH_REQ]]] { // io_uring_sqe_uring[fd_ublk_ch, const[UBLK_U_IO_FETCH_REQ, int32], // ublk_io_cmd$fetch_req, user_data[UBLK_U_IO_FETCH_REQ]] { // opcode: const = 0x2e (1 bytes) // flags: iosqe_flags = 0x0 (1 bytes) // ioprio: const = 0x0 (2 bytes) // fd: fd_ublk_ch (resource) // cmd_op: const = 0xc0107520 (4 bytes) // pad1: const = 0x0 (4 bytes) // addr: const = 0x0 (8 bytes) // len: const = 0x0 (4 bytes) // uring_flags: uring_cmd_flags = 0x0 (4 bytes) // user_data: user_data[UBLK_U_IO_FETCH_REQ] { // tag: int64 = 0x0 (0 bytes) // cmd: const = 0xc0107520 (0 bytes) // pad: const = 0x0 (8 bytes) // } // buf_index_unused: const = 0x0 (2 bytes) // ioring_personality_id: ioring_personality_id (resource) // pad_unused: buffer: {00 00 00 00} (length 0x4) // cmd: ublk_io_cmd[int16[0:UBLK_MAX_HW_QUEUES], // int16[0:UBLK_MAX_QUEUE_DEPTH], const[0, int32], ptr64[inout, // ublk_io_buf_u]] { // q_id: int16 = 0x0 (2 bytes) // tag: int16 = 0x0 (2 bytes) // result: const = 0x0 (4 bytes) // addr: nil // pad: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00} (length 0x40) // } // } // } // ublk_queues_ptr: nil // ] *(uint32_t*)0x20000704 = 0; *(uint32_t*)0x20000708 = 0; *(uint32_t*)0x2000070c = 0; *(uint32_t*)0x20000710 = 0; *(uint32_t*)0x20000718 = -1; memset((void*)0x2000071c, 0, 12); *(uint32_t*)0x2000080c = 0; *(uint32_t*)0x20000810 = 0; *(uint32_t*)0x20000814 = 1; *(uint32_t*)0x20000818 = 0; *(uint32_t*)0x20000820 = -1; *(uint32_t*)0x200008ac = 0; *(uint32_t*)0x200008b0 = 0; *(uint32_t*)0x200008b4 = 0; *(uint32_t*)0x200008b8 = 0; *(uint32_t*)0x200008c0 = -1; *(uint32_t*)0x2000094c = 0xb026; *(uint32_t*)0x20000950 = 0; *(uint32_t*)0x20000954 = 0; *(uint32_t*)0x20000958 = 0; *(uint32_t*)0x20000960 = r[1]; *(uint32_t*)0x200009ec = 0; *(uint32_t*)0x200009f0 = 0x2000; *(uint32_t*)0x200009f4 = 0; *(uint32_t*)0x200009f8 = 0; *(uint32_t*)0x20000a00 = -1; *(uint8_t*)0x20000900 = 0x2e; *(uint8_t*)0x20000901 = 0; *(uint16_t*)0x20000902 = 0; *(uint32_t*)0x20000904 = r[7]; *(uint32_t*)0x20000908 = 0xc0107520; *(uint32_t*)0x2000090c = 0; *(uint64_t*)0x20000910 = 0; *(uint32_t*)0x20000918 = 0; *(uint32_t*)0x2000091c = 0; STORE_BY_BITMASK(uint64_t, , 0x20000920, 0, 0, 16); STORE_BY_BITMASK(uint64_t, , 0x20000920, 0xc0107520, 16, 32); STORE_BY_BITMASK(uint64_t, , 0x20000920, 0, 48, 16); *(uint16_t*)0x20000928 = 0; *(uint16_t*)0x2000092a = 0; memset((void*)0x2000092c, 0, 4); *(uint16_t*)0x20000930 = 0; *(uint16_t*)0x20000932 = 0; *(uint32_t*)0x20000934 = 0; *(uint64_t*)0x20000938 = 0; memset((void*)0x20000940, 0, 64); syz_ublk_setup_queues(/*fd_ublk_ch=*/r[7], /*dev_info_ptr=*/r[6], /*params=*/0x20000700, /*queues=*/0x20000800, /*nr_queues=*/1, /*sqe=*/0x20000900, /*ublk_queues_ptr=*/0); break; case 5: // openat$ublk_ctrl arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 75 62 6c 6b 2d 63 6f 6e 74 72 6f 6c 00} // (length 0x12) // } // flags: const = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_ublk_ctrl memcpy((void*)0x20000000, "/dev/ublk-control\000", 18); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000000ul, /*flags=*/2, /*mode=*/0); if (res != -1) r[8] = res; break; case 6: // syz_ublk_setup_io_uring arguments: [ // entries: int32 = 0x20 (4 bytes) // params: ptr[inout, io_uring_params] { // io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x0 (4 bytes) // flags: io_uring_setup_flags = 0x0 (4 bytes) // sq_thread_cpu: int32 = 0x0 (4 bytes) // sq_thread_idle: int32 = 0x0 (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) // } // } // } // ring_params_ptr: ptr[out, ring_params_ptr] { // ring_params_ptr (resource) // } // ring_ptr: ptr[out, ring_ptr] { // ring_ptr (resource) // } // sqes_ptr: ptr[out, sqes_ptr] { // sqes_ptr (resource) // } // ] // returns fd_io_uring *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x2000004c = 0; *(uint32_t*)0x20000050 = 0; *(uint32_t*)0x20000058 = -1; memset((void*)0x2000005c, 0, 12); res = -1; res = syz_ublk_setup_io_uring( /*entries=*/0x20, /*params=*/0x20000040, /*ring_params_ptr=*/0x200000c0, /*ring_ptr=*/0x20000100, /*sqes_ptr=*/0x20000140); if (res != -1) { r[9] = res; r[10] = *(uint64_t*)0x200000c0; r[11] = *(uint64_t*)0x20000100; r[12] = *(uint64_t*)0x20000140; } break; case 7: // syz_io_uring_submit$UBLK arguments: [ // ring_params_ptr: ring_params_ptr (resource) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // sqe: ptr[inout, ublk_cmd_sqe_u] { // union ublk_cmd_sqe_u { // ublk_set_params_sqe: io_uring_sqe_uring[fd_ublk_ctrl, // const[UBLK_U_CMD_SET_PARAMS, int32], ublk_ctrl_cmd$set_params, // int64] { // opcode: const = 0x2e (1 bytes) // flags: iosqe_flags = 0x0 (1 bytes) // ioprio: const = 0x0 (2 bytes) // fd: fd_ublk_ctrl (resource) // cmd_op: const = 0xc0207508 (4 bytes) // pad1: const = 0x0 (4 bytes) // addr: const = 0x0 (8 bytes) // len: const = 0x0 (4 bytes) // uring_flags: uring_cmd_flags = 0x0 (4 bytes) // user_data: int64 = 0x0 (8 bytes) // buf_index_unused: const = 0x0 (2 bytes) // ioring_personality_id: ioring_personality_id (resource) // pad_unused: buffer: {00 00 00 00} (length 0x4) // cmd: ublk_ctrl_cmd[ublk_dev_id, len[addr, int16], ptr64[in, // ublk_params], const[0, int64]] { // dev_id: ublk_dev_id (resource) // queue_id: const = 0xffff (2 bytes) // len: len = 0x70 (2 bytes) // addr: ptr[in, ublk_params] { // ublk_params { // len: len = 0x70 (4 bytes) // types: ublk_param_types = 0x1 (4 bytes) // basic: ublk_param_basic { // attrs: ublk_attr_flags = 0x0 (4 bytes) // logical_bs_shift: int8 = 0x9 (1 bytes) // physical_bs_shift: int8 = 0xc (1 bytes) // io_opt_shift: int8 = 0xc (1 bytes) // io_min_shift: int8 = 0x9 (1 bytes) // max_sectors: int32 = 0x8 (4 bytes) // chunk_sectors: int32 = 0x0 (4 bytes) // dev_sectors: int64 = 0x2 (8 bytes) // virt_boundary_mask: int64 = 0x0 (8 bytes) // } // discard: ublk_param_discard { // discard_alignment: int32 = 0x0 (4 bytes) // discard_granularity: int32 = 0x0 (4 bytes) // max_discard_sectors: int32 = 0x0 (4 bytes) // max_write_zeroes_sectors: int32 = 0x0 (4 bytes) // max_discard_segments: int16 = 0x0 (2 bytes) // reserved0: const = 0x0 (2 bytes) // } // devt: ublk_param_devt { // char_major: int32 = 0x0 (4 bytes) // char_minor: int32 = 0x0 (4 bytes) // disk_major: int32 = 0x0 (4 bytes) // disk_minor: int32 = 0x0 (4 bytes) // } // zoned: ublk_param_zoned { // max_open_zones: int32 = 0x0 (4 bytes) // max_active_zones: int32 = 0x0 (4 bytes) // max_zone_append_sectors: int32 = 0x0 (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00} (length 0x14) // } // pad = 0x0 (4 bytes) // } // } // data: const = 0x0 (8 bytes) // dev_path_len: const = 0x0 (2 bytes) // pad: const = 0x0 (2 bytes) // reserved: const = 0x0 (4 bytes) // pad2_unused: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x30) // } // } // } // } // ] *(uint8_t*)0x20000600 = 0x2e; *(uint8_t*)0x20000601 = 0; *(uint16_t*)0x20000602 = 0; *(uint32_t*)0x20000604 = r[8]; *(uint32_t*)0x20000608 = 0xc0207508; *(uint32_t*)0x2000060c = 0; *(uint64_t*)0x20000610 = 0; *(uint32_t*)0x20000618 = 0; *(uint32_t*)0x2000061c = 0; *(uint64_t*)0x20000620 = 0; *(uint16_t*)0x20000628 = 0; *(uint16_t*)0x2000062a = 0; memset((void*)0x2000062c, 0, 4); *(uint32_t*)0x20000630 = 0; *(uint16_t*)0x20000634 = -1; *(uint16_t*)0x20000636 = 0x70; *(uint64_t*)0x20000638 = 0x20000680; *(uint32_t*)0x20000680 = 0x70; *(uint32_t*)0x20000684 = 1; *(uint32_t*)0x20000688 = 0; *(uint8_t*)0x2000068c = 9; *(uint8_t*)0x2000068d = 0xc; *(uint8_t*)0x2000068e = 0xc; *(uint8_t*)0x2000068f = 9; *(uint32_t*)0x20000690 = 8; *(uint32_t*)0x20000694 = 0; *(uint64_t*)0x20000698 = 2; *(uint64_t*)0x200006a0 = 0; *(uint32_t*)0x200006a8 = 0; *(uint32_t*)0x200006ac = 0; *(uint32_t*)0x200006b0 = 0; *(uint32_t*)0x200006b4 = 0; *(uint16_t*)0x200006b8 = 0; *(uint16_t*)0x200006ba = 0; *(uint32_t*)0x200006bc = 0; *(uint32_t*)0x200006c0 = 0; *(uint32_t*)0x200006c4 = 0; *(uint32_t*)0x200006c8 = 0; *(uint32_t*)0x200006cc = 0; *(uint32_t*)0x200006d0 = 0; *(uint32_t*)0x200006d4 = 0; memset((void*)0x200006d8, 0, 20); *(uint64_t*)0x20000640 = 0; *(uint16_t*)0x20000648 = 0; *(uint16_t*)0x2000064a = 0; *(uint32_t*)0x2000064c = 0; memset((void*)0x20000650, 0, 48); syz_io_uring_submit(/*ring_params_ptr=*/r[10], /*ring_ptr=*/r[11], /*sqes_ptr=*/r[12], /*sqe=*/0x20000600); break; case 8: // io_uring_enter arguments: [ // fd: fd_io_uring (resource) // to_submit: int32 = 0x1 (4 bytes) // min_complete: int32 = 0x1 (4 bytes) // flags: io_uring_enter_flags = 0x1 (8 bytes) // sigmask: nil // size: len = 0x0 (8 bytes) // ] syscall(__NR_io_uring_enter, /*fd=*/r[9], /*to_submit=*/1, /*min_complete=*/1, /*flags=IORING_ENTER_GETEVENTS*/ 1ul, /*sigmask=*/0ul, /*size=*/0ul); break; case 9: // getpid arguments: [ // ] // returns pid res = syscall(__NR_getpid); if (res != -1) r[13] = res; break; case 10: // syz_io_uring_submit$UBLK arguments: [ // ring_params_ptr: ring_params_ptr (resource) // ring_ptr: ring_ptr (resource) // sqes_ptr: sqes_ptr (resource) // sqe: ptr[inout, ublk_cmd_sqe_u] { // union ublk_cmd_sqe_u { // ublk_start_dev_sqe: io_uring_sqe_uring[fd_ublk_ctrl, // const[UBLK_U_CMD_START_DEV, int32], ublk_ctrl_cmd$start_dev, // int64] { // opcode: const = 0x2e (1 bytes) // flags: iosqe_flags = 0x0 (1 bytes) // ioprio: const = 0x0 (2 bytes) // fd: fd_ublk_ctrl (resource) // cmd_op: const = 0xc0207506 (4 bytes) // pad1: const = 0x0 (4 bytes) // addr: const = 0x0 (8 bytes) // len: const = 0x0 (4 bytes) // uring_flags: uring_cmd_flags = 0x0 (4 bytes) // user_data: int64 = 0x0 (8 bytes) // buf_index_unused: const = 0x0 (2 bytes) // ioring_personality_id: ioring_personality_id (resource) // pad_unused: buffer: {00 00 00 00} (length 0x4) // cmd: ublk_ctrl_cmd[ublk_dev_id, const[0, int16], const[0, // int64], pid] { // dev_id: ublk_dev_id (resource) // queue_id: const = 0xffff (2 bytes) // len: const = 0x0 (2 bytes) // addr: const = 0x0 (8 bytes) // data: pid (resource) // dev_path_len: const = 0x0 (2 bytes) // pad: const = 0x0 (2 bytes) // reserved: const = 0x0 (4 bytes) // pad2_unused: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x30) pad = // 0x0 (4 bytes) // } // } // } // } // ] *(uint8_t*)0x20000c00 = 0x2e; *(uint8_t*)0x20000c01 = 0; *(uint16_t*)0x20000c02 = 0; *(uint32_t*)0x20000c04 = r[8]; *(uint32_t*)0x20000c08 = 0xc0207506; *(uint32_t*)0x20000c0c = 0; *(uint64_t*)0x20000c10 = 0; *(uint32_t*)0x20000c18 = 0; *(uint32_t*)0x20000c1c = 0; *(uint64_t*)0x20000c20 = 0; *(uint16_t*)0x20000c28 = 0; *(uint16_t*)0x20000c2a = 0; memset((void*)0x20000c2c, 0, 4); *(uint32_t*)0x20000c30 = 0; *(uint16_t*)0x20000c34 = -1; *(uint16_t*)0x20000c36 = 0; *(uint64_t*)0x20000c38 = 0; *(uint32_t*)0x20000c40 = r[13]; *(uint16_t*)0x20000c44 = 0; *(uint16_t*)0x20000c46 = 0; *(uint32_t*)0x20000c48 = 0; memset((void*)0x20000c4c, 0, 48); syz_io_uring_submit(/*ring_params_ptr=*/r[10], /*ring_ptr=*/r[11], /*sqes_ptr=*/r[12], /*sqe=*/0x20000c00); break; case 11: // io_uring_enter arguments: [ // fd: fd_io_uring (resource) // to_submit: int32 = 0x1 (4 bytes) // min_complete: int32 = 0x1 (4 bytes) // flags: io_uring_enter_flags = 0x1 (8 bytes) // sigmask: nil // size: len = 0x0 (8 bytes) // ] syscall(__NR_io_uring_enter, /*fd=*/r[9], /*to_submit=*/1, /*min_complete=*/1, /*flags=IORING_ENTER_GETEVENTS*/ 1ul, /*sigmask=*/0ul, /*size=*/0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*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=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }