io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check
PATCH 1/1 io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check
From: Nicholas Carlini <[email protected]>
__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.
--- io_uring/fdinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
io_uring/fdinfo.c +2 -1
@@ -119,12 +119,13 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) sq_idx);break ; } -if ((++sq_head & sq_mask) ==0 ) { +if (sq_idx == sq_mask) {seq_printf (m,"%5u: corrupted sqe, wrapping 128B entry\n" , sq_idx);break ; } + sq_head++; sqe128 = true; } seq_printf(m, "%5u: opcode:%s, fd:%d, flags:%x, off:%llu, "
--
2.39.5
Quoted 9 lines · On Fri, 27 Mar 2026 02:18:23 +0000, [email protected] wrote:
__io_uring_show_fdinfo()iterates over pending SQEs and, for 128-byte SQEs on anIORING_SETUP_SQE_MIXEDring, needs to detect when the second half of the SQE would be past the end of thesq_sqesarray. The current check tests (++sq_head &sq_mask) == 0, butsq_headis only incremented when a 128-byte SQE is encountered, not on every iteration. The actual array index issq_idx= (i +sq_head) &sq_mask, which can besq_mask(the last slot) while the wrap check passes.[...]
Applied, thanks!
[1/1] io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check
commit: 5170efd9c344c68a8075dcb8ed38d3f8a60e7ed4
Best regards,
Signature · 1 line
Jens Axboe