two small rsrc infra patches
cover two small rsrc infra patches
Small unrelated changes
Pavel Begunkov (2):
io_uring: zero tag on rsrc removal
io_uring: use nospec annotation for more indexes
fs/io_uring.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/2 io_uring: zero tag on rsrc removal
Automatically default rsrc tag in io_queue_rsrc_removal(), it's safer than leaving it there and relying on the rest of the code to behave and not use it.
Signed-off-by Pavel Begunkov <[email protected]>
--- fs/io_uring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/io_uring.c +3 -1
@@ -8848,13 +8848,15 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,static int io_queue_rsrc_removal (struct io_rsrc_data *data,unsigned idx,struct io_rsrc_node *node,void *rsrc) { +u64 *tag_slot =io_get_tag_slot (data, idx);struct io_rsrc_put *prsrc; prsrc =kzalloc (sizeof (*prsrc),GFP_KERNEL );if (!prsrc)return -ENOMEM ; - prsrc->tag = *io_get_tag_slot (data, idx); + prsrc->tag = *tag_slot; + *tag_slot =0 ; prsrc->rsrc = rsrc;list_add (&prsrc->list, &node->rsrc_list);return 0 ;
Signature · 1 line
2.35.1
PATCH 2/2 io_uring: use nospec annotation for more indexes
In reply to Pavel BegunkovThere are still several places that using pre array_index_nospec() indexes, fix them up.
Signed-off-by Pavel Begunkov <[email protected]>
--- fs/io_uring.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/io_uring.c +5 -6
@@ -8919,7 +8919,7 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)struct io_ring_ctx *ctx = req->ctx;struct io_fixed_file *file_slot;struct file *file; -int ret, i; +int ret;io_ring_submit_lock (ctx, issue_flags); ret = -ENXIO ;
@@ -8932,8 +8932,8 @@ static int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)if (ret) goto out; - i =array_index_nospec (offset, ctx->nr_user_files); - file_slot =io_fixed_file_slot (&ctx->file_table, i); + offset =array_index_nospec (offset, ctx->nr_user_files); + file_slot =io_fixed_file_slot (&ctx->file_table, offset); ret = -EBADF ;if (!file_slot->file_ptr) goto out;
@@ -8989,8 +8989,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,if (file_slot->file_ptr) { file = (struct file *)(file_slot->file_ptr &FFS_MASK ); - err =io_queue_rsrc_removal (data, up->offset + done, - ctx->rsrc_node, file); + err =io_queue_rsrc_removal (data, i, ctx->rsrc_node, file);if (err)break ; file_slot->file_ptr =0 ;
@@ -9672,7 +9671,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx, i =array_index_nospec (offset, ctx->nr_user_bufs);if (ctx->user_bufs[i] != ctx->dummy_ubuf) { - err =io_queue_rsrc_removal (ctx->buf_data, offset, + err =io_queue_rsrc_removal (ctx->buf_data, i, ctx->rsrc_node, ctx->user_bufs[i]);if (unlikely (err)) {io_buffer_unmap (ctx, &imu);
Signature · 1 line
2.35.1
Quoted 10 lines · Pavel Begunkov
Small unrelated changes
Pavel Begunkov (2):
io_uring: zero tag on rsrc removal
io_uring: use nospec annotation for more indexes
fs/io_uring.c| 15 ++++++++-------1 file changed, 8 insertions(+), 7 deletions(-)[...]
Applied, thanks!
[1/2] io_uring: zero tag on rsrc removal
commit: 3aa3bc4fa93acaac8ffb31fd09f14399924740bb
[2/2] io_uring: use nospec annotation for more indexes
commit: b5e400c9542fdeca2015d4df7672cbf14d40746fBest regards,
Signature · 1 line
Jens Axboe