Skip to contentSkip to conversation

io_uring: protect fixed file indexing with array_index_nospec()

PATCH New Jens Axboe 1 participant 1 message Oct 26, 2019

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 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.

---

fs/io_uring.c +1 -0
index 4402485f0879..769a8c7eee37 100644
@@ -2320,6 +2320,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];
Signature · 1 line
Jens Axboe