Skip to content

Commit b8ed0f7

Browse files
isilencegregkh
authored andcommitted
io_uring: use nospec annotation for more indexes
[ Upstream commit 4cdd158 ] There are still several places that using pre array_index_nospec() indexes, fix them up. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/b01ef5ee83f72ed35ad525912370b729f5d145f4.1649336342.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5218d5c commit b8ed0f7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

fs/io_uring.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8489,7 +8489,7 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)
84898489
struct io_ring_ctx *ctx = req->ctx;
84908490
struct io_fixed_file *file_slot;
84918491
struct file *file;
8492-
int ret, i;
8492+
int ret;
84938493

84948494
io_ring_submit_lock(ctx, !(issue_flags & IO_URING_F_NONBLOCK));
84958495
ret = -ENXIO;
@@ -8502,8 +8502,8 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)
85028502
if (ret)
85038503
goto out;
85048504

8505-
i = array_index_nospec(offset, ctx->nr_user_files);
8506-
file_slot = io_fixed_file_slot(&ctx->file_table, i);
8505+
offset = array_index_nospec(offset, ctx->nr_user_files);
8506+
file_slot = io_fixed_file_slot(&ctx->file_table, offset);
85078507
ret = -EBADF;
85088508
if (!file_slot->file_ptr)
85098509
goto out;
@@ -8559,8 +8559,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
85598559

85608560
if (file_slot->file_ptr) {
85618561
file = (struct file *)(file_slot->file_ptr & FFS_MASK);
8562-
err = io_queue_rsrc_removal(data, up->offset + done,
8563-
ctx->rsrc_node, file);
8562+
err = io_queue_rsrc_removal(data, i, ctx->rsrc_node, file);
85648563
if (err)
85658564
break;
85668565
file_slot->file_ptr = 0;
@@ -9229,7 +9228,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
92299228

92309229
i = array_index_nospec(offset, ctx->nr_user_bufs);
92319230
if (ctx->user_bufs[i] != ctx->dummy_ubuf) {
9232-
err = io_queue_rsrc_removal(ctx->buf_data, offset,
9231+
err = io_queue_rsrc_removal(ctx->buf_data, i,
92339232
ctx->rsrc_node, ctx->user_bufs[i]);
92349233
if (unlikely(err)) {
92359234
io_buffer_unmap(ctx, &imu);

0 commit comments

Comments
 (0)