Skip to content

Commit 4cdd158

Browse files
isilenceaxboe
authored andcommitted
io_uring: use nospec annotation for more indexes
There are still several places that using pre array_index_nospec() indexes, fix them up. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/b01ef5ee83f72ed35ad525912370b729f5d145f4.1649336342.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8f0a248 commit 4cdd158

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
@@ -9004,7 +9004,7 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)
90049004
bool needs_lock = issue_flags & IO_URING_F_UNLOCKED;
90059005
struct io_fixed_file *file_slot;
90069006
struct file *file;
9007-
int ret, i;
9007+
int ret;
90089008

90099009
io_ring_submit_lock(ctx, needs_lock);
90109010
ret = -ENXIO;
@@ -9017,8 +9017,8 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)
90179017
if (ret)
90189018
goto out;
90199019

9020-
i = array_index_nospec(offset, ctx->nr_user_files);
9021-
file_slot = io_fixed_file_slot(&ctx->file_table, i);
9020+
offset = array_index_nospec(offset, ctx->nr_user_files);
9021+
file_slot = io_fixed_file_slot(&ctx->file_table, offset);
90229022
ret = -EBADF;
90239023
if (!file_slot->file_ptr)
90249024
goto out;
@@ -9074,8 +9074,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
90749074

90759075
if (file_slot->file_ptr) {
90769076
file = (struct file *)(file_slot->file_ptr & FFS_MASK);
9077-
err = io_queue_rsrc_removal(data, up->offset + done,
9078-
ctx->rsrc_node, file);
9077+
err = io_queue_rsrc_removal(data, i, ctx->rsrc_node, file);
90799078
if (err)
90809079
break;
90819080
file_slot->file_ptr = 0;
@@ -9758,7 +9757,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
97589757

97599758
i = array_index_nospec(offset, ctx->nr_user_bufs);
97609759
if (ctx->user_bufs[i] != ctx->dummy_ubuf) {
9761-
err = io_queue_rsrc_removal(ctx->buf_data, offset,
9760+
err = io_queue_rsrc_removal(ctx->buf_data, i,
97629761
ctx->rsrc_node, ctx->user_bufs[i]);
97639762
if (unlikely(err)) {
97649763
io_buffer_unmap(ctx, &imu);

0 commit comments

Comments
 (0)