From: Jens Axboe Date: Sat, 26 Oct 2019 13:22:55 +0000 (-0600) Subject: io_uring: protect fixed file indexing with array_index_nospec() X-Git-Tag: v5.5-rc1~204^2~48 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b7620121dc04e44ce654297050f9eaf39d414a34;p=users%2Fjedix%2Flinux-maple.git io_uring: protect fixed file indexing with array_index_nospec() We index the file tables with a user given value. After we check it's within our limits, use array_index_nospec() to prevent any spectre attacks here. Suggested-by: Jann Horn Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index b668149c20b9..7743b180a3e0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2321,6 +2321,7 @@ static int io_req_set_file(struct io_ring_ctx *ctx, const struct sqe_submit *s, if (unlikely(!ctx->user_files || (unsigned) fd >= ctx->nr_user_files)) return -EBADF; + fd = array_index_nospec(fd, ctx->nr_user_files); if (!ctx->user_files[fd]) return -EBADF; req->file = ctx->user_files[fd];