Skip to content

Commit 5170efd

Browse files
carliniaxboe
authored andcommitted
io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check
__io_uring_show_fdinfo() iterates over pending SQEs and, for 128-byte SQEs on an IORING_SETUP_SQE_MIXED ring, needs to detect when the second half of the SQE would be past the end of the sq_sqes array. The current check tests (++sq_head & sq_mask) == 0, but sq_head is only incremented when a 128-byte SQE is encountered, not on every iteration. The actual array index is sq_idx = (i + sq_head) & sq_mask, which can be sq_mask (the last slot) while the wrap check passes. Fix by checking sq_idx directly. Keep the sq_head increment so the loop still skips the second half of the 128-byte SQE on the next iteration. Fixes: 1cba30b ("io_uring: add support for IORING_SETUP_SQE_MIXED") Signed-off-by: Nicholas Carlini <nicholas@carlini.com> Link: https://patch.msgid.link/20260327021823.3138396-1-nicholas@carlini.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b59efde commit 5170efd

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

io_uring/fdinfo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
119119
sq_idx);
120120
break;
121121
}
122-
if ((++sq_head & sq_mask) == 0) {
122+
if (sq_idx == sq_mask) {
123123
seq_printf(m,
124124
"%5u: corrupted sqe, wrapping 128B entry\n",
125125
sq_idx);
126126
break;
127127
}
128+
sq_head++;
128129
i++;
129130
sqe128 = true;
130131
}

0 commit comments

Comments
 (0)