// https://syzkaller.appspot.com/bug?id=177b7335bdaa7e7cfeb29e055acc7877167a82ff // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #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 sys_io_uring_setup 425 static long syz_io_uring_setup(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4, volatile long a5) { uint32_t entries = (uint32_t)a0; struct io_uring_params* setup_params = (struct io_uring_params*)a1; void* vma1 = (void*)a2; void* vma2 = (void*)a3; void** ring_ptr_out = (void**)a4; void** sqes_ptr_out = (void**)a5; uint32_t fd_io_uring = syscall(sys_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(vma1, ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd_io_uring, IORING_OFF_SQ_RING); uint32_t sqes_sz = setup_params->sq_entries * SIZEOF_IO_URING_SQE; *sqes_ptr_out = mmap(vma2, sqes_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd_io_uring, IORING_OFF_SQES); return fd_io_uring; } 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 { char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } uint64_t r[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); intptr_t res = 0; *(uint32_t*)0x20000084 = 0; *(uint32_t*)0x20000088 = 0; *(uint32_t*)0x2000008c = 0; *(uint32_t*)0x20000090 = 0; *(uint32_t*)0x20000098 = -1; *(uint32_t*)0x2000009c = 0; *(uint32_t*)0x200000a0 = 0; *(uint32_t*)0x200000a4 = 0; syz_io_uring_setup(0x4439, 0x20000080, 0x20ffb000, 0x206d4000, 0, 0); memcpy((void*)0x20000000, "/dev/vbi#\000", 10); res = -1; res = syz_open_dev(0x20000000, 3, 2); if (res != -1) r[0] = res; *(uint32_t*)0x20000040 = 3; *(uint32_t*)0x20000044 = 5; *(uint32_t*)0x20000048 = 2; *(uint32_t*)0x2000004c = 0; *(uint32_t*)0x20000050 = 0; syscall(__NR_ioctl, r[0], 0xc0145608, 0x20000040ul); *(uint32_t*)0x20000140 = 0; *(uint32_t*)0x20000144 = 5; *(uint32_t*)0x20000148 = 4; *(uint32_t*)0x2000014c = 0; *(uint32_t*)0x20000150 = 0; *(uint64_t*)0x20000158 = 0; *(uint64_t*)0x20000160 = 0; *(uint32_t*)0x20000168 = 0; *(uint32_t*)0x2000016c = 0; *(uint8_t*)0x20000170 = 0; *(uint8_t*)0x20000171 = 0; *(uint8_t*)0x20000172 = 0; *(uint8_t*)0x20000173 = 0; memcpy((void*)0x20000174, "\xbc\x4c\x74\xc7", 4); *(uint32_t*)0x20000178 = 0; *(uint32_t*)0x2000017c = 2; *(uint32_t*)0x20000180 = 0x21000000; *(uint32_t*)0x20000188 = 0x10ff00; *(uint32_t*)0x2000018c = 0x500; *(uint32_t*)0x20000190 = -1; syscall(__NR_ioctl, r[0], 0xc058560f, 0x20000140ul); return 0; }