Skip to content

Commit 29b95ac

Browse files
isilenceaxboe
authored andcommitted
io_uring: prevent reg-wait speculations
With *ENTER_EXT_ARG_REG instead of passing a user pointer with arguments for the waiting loop the user can specify an offset into a pre-mapped region of memory, in which case the [offset, offset + sizeof(io_uring_reg_wait)) will be intepreted as the argument. As we address a kernel array using a user given index, it'd be a subject to speculation type of exploits. Use array_index_nospec() to prevent that. Make sure to pass not the full region size but truncate by the maximum offset allowed considering the structure size. Fixes: d617b31 ("io_uring: restore back registered wait arguments") Fixes: aa00f67 ("io_uring: add support for fixed wait regions") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/1e3d9da7c43d619de7bcf41d1cd277ab2688c443.1733694126.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent de3b9e2 commit 29b95ac

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

io_uring/io_uring.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,7 @@ static struct io_uring_reg_wait *io_get_ext_arg_reg(struct io_ring_ctx *ctx,
32113211
end > ctx->cq_wait_size))
32123212
return ERR_PTR(-EFAULT);
32133213

3214+
offset = array_index_nospec(offset, ctx->cq_wait_size - size);
32143215
return ctx->cq_wait_arg + offset;
32153216
}
32163217

0 commit comments

Comments
 (0)