// https://syzkaller.appspot.com/bug?id=7f2c87f4c360bcb8419c1cd55853d16cb89edbac // 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 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; } #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"); } 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[8] = { 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // 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*)0x200000000000, "/dev/ublk-control\000", 18); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000000ul, /*flags=*/2, /*mode=*/0); if (res != -1) r[0] = res; // 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*)0x200000000044 = 0; *(uint32_t*)0x200000000048 = 0; *(uint32_t*)0x20000000004c = 0; *(uint32_t*)0x200000000050 = 0; *(uint32_t*)0x200000000058 = -1; memset((void*)0x20000000005c, 0, 12); res = -1; res = syz_ublk_setup_io_uring(/*entries=*/0x20, /*params=*/0x200000000040, /*ring_params_ptr=*/0x2000000000c0, /*ring_ptr=*/0x200000000100, /*sqes_ptr=*/0x200000000140); if (res != -1) { r[1] = res; r[2] = *(uint64_t*)0x2000000000c0; r[3] = *(uint64_t*)0x200000000100; r[4] = *(uint64_t*)0x200000000140; } // 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*)0x200000000200 = 0x2e; *(uint8_t*)0x200000000201 = 0; *(uint16_t*)0x200000000202 = 0; *(uint32_t*)0x200000000204 = r[0]; *(uint32_t*)0x200000000208 = 0xc0207504; *(uint32_t*)0x20000000020c = 0; *(uint64_t*)0x200000000210 = 0; *(uint32_t*)0x200000000218 = 0; *(uint32_t*)0x20000000021c = 0; *(uint64_t*)0x200000000220 = 0; *(uint16_t*)0x200000000228 = 0; *(uint16_t*)0x20000000022a = 0; memset((void*)0x20000000022c, 0, 4); *(uint32_t*)0x200000000230 = -1; *(uint16_t*)0x200000000234 = -1; *(uint16_t*)0x200000000236 = 0x48; *(uint64_t*)0x200000000238 = 0x200000000500; *(uint16_t*)0x200000000500 = 1; *(uint16_t*)0x200000000502 = 4; *(uint16_t*)0x200000000504 = 0; *(uint16_t*)0x200000000506 = 0; *(uint32_t*)0x200000000508 = 0x1000; *(uint32_t*)0x20000000050c = -1; *(uint32_t*)0x200000000510 = 0; *(uint32_t*)0x200000000514 = 0; *(uint64_t*)0x200000000518 = 0; *(uint64_t*)0x200000000520 = 0; *(uint32_t*)0x200000000528 = 0; *(uint32_t*)0x20000000052c = 0; *(uint64_t*)0x200000000530 = 0; *(uint64_t*)0x200000000538 = 0; *(uint64_t*)0x200000000240 = 0; *(uint16_t*)0x200000000248 = 0; *(uint16_t*)0x20000000024a = 0; *(uint32_t*)0x20000000024c = 0; memset((void*)0x200000000250, 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=*/0x200000000200, /*dev_info_ptr=*/0x200000000300); if (res != -1) { r[5] = res; r[6] = *(uint64_t*)0x200000000300; } // 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*)0x200000002000, "/dev/ublkc#\000", 12); res = -1; res = syz_open_dev(/*dev=*/0x200000002000, /*id=*/r[5], /*flags=O_RDWR*/ 2); if (res != -1) r[7] = res; // 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 = 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 = 0x1000 (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 = 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 = 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) // } // } // } // 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 = 0x2 (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*)0x200000000704 = 0; *(uint32_t*)0x200000000708 = 0; *(uint32_t*)0x20000000070c = 0; *(uint32_t*)0x200000000710 = 0; *(uint32_t*)0x200000000718 = -1; memset((void*)0x20000000071c, 0, 12); *(uint32_t*)0x20000000080c = 0; *(uint32_t*)0x200000000810 = 0; *(uint32_t*)0x200000000814 = 0; *(uint32_t*)0x200000000818 = 0; *(uint32_t*)0x200000000820 = -1; *(uint32_t*)0x2000000008ac = 0x1000; *(uint32_t*)0x2000000008b0 = 0; *(uint32_t*)0x2000000008b4 = 0; *(uint32_t*)0x2000000008b8 = 0; *(uint32_t*)0x2000000008c0 = -1; *(uint32_t*)0x20000000094c = 0; *(uint32_t*)0x200000000950 = 0; *(uint32_t*)0x200000000954 = 0; *(uint32_t*)0x200000000958 = 0; *(uint32_t*)0x200000000960 = -1; *(uint32_t*)0x2000000009ec = 0; *(uint32_t*)0x2000000009f0 = 0; *(uint32_t*)0x2000000009f4 = 0; *(uint32_t*)0x2000000009f8 = 0; *(uint32_t*)0x200000000a00 = -1; *(uint8_t*)0x200000000900 = 0x2e; *(uint8_t*)0x200000000901 = 2; *(uint16_t*)0x200000000902 = 0; *(uint32_t*)0x200000000904 = r[7]; *(uint32_t*)0x200000000908 = 0xc0107520; *(uint32_t*)0x20000000090c = 0; *(uint64_t*)0x200000000910 = 0; *(uint32_t*)0x200000000918 = 0; *(uint32_t*)0x20000000091c = 0; STORE_BY_BITMASK(uint64_t, , 0x200000000920, 0, 0, 16); STORE_BY_BITMASK(uint64_t, , 0x200000000920, 0xc0107520, 16, 32); STORE_BY_BITMASK(uint64_t, , 0x200000000920, 0, 48, 16); *(uint16_t*)0x200000000928 = 0; *(uint16_t*)0x20000000092a = 0; memset((void*)0x20000000092c, 0, 4); *(uint16_t*)0x200000000930 = 0; *(uint16_t*)0x200000000932 = 0; *(uint32_t*)0x200000000934 = 0; *(uint64_t*)0x200000000938 = 0; memset((void*)0x200000000940, 0, 64); syz_ublk_setup_queues(/*fd_ublk_ch=*/r[7], /*dev_info_ptr=*/r[6], /*params=*/0x200000000700, /*queues=*/0x200000000800, /*nr_queues=*/1, /*sqe=*/0x200000000900, /*ublk_queues_ptr=*/0); } 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; loop(); return 0; }