io_uring: prevent reg-wait speculations
PATCH v2 1/1 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.
---
v2: use array_index_nospec()
io_uring/io_uring.c | 1 + 1 file changed, 1 insertion(+)
io_uring/io_uring.c +1 -0
@@ -3213,6 +3213,7 @@ static struct io_uring_reg_wait *io_get_ext_arg_reg(struct io_ring_ctx *ctx, end > ctx->cq_wait_size))return ERR_PTR (-EFAULT ); + offset =array_index_nospec (offset, ctx->cq_wait_size - size);return ctx->cq_wait_arg + offset; }
Signature · 1 line
2.47.1
Quoted 6 lines · Pavel Begunkov
With
*ENTER_EXT_ARG_REGinstead 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.
Quoted 6 lines
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.[...]
Applied, thanks!
[1/1] io_uring: prevent reg-wait speculations
commit: f137f14b7ccb78d274430d11b4526617d90739a1
Best regards,
Signature · 1 line
Jens Axboe