* [PATCH 0/2] two small rsrc infra patches
@ 2022-04-07 13:05 Pavel Begunkov
2022-04-07 13:05 ` [PATCH 1/2] io_uring: zero tag on rsrc removal Pavel Begunkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-04-07 13:05 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
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(-)
--
2.35.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] io_uring: zero tag on rsrc removal
2022-04-07 13:05 [PATCH 0/2] two small rsrc infra patches Pavel Begunkov
@ 2022-04-07 13:05 ` Pavel Begunkov
2022-04-07 13:05 ` [PATCH 2/2] io_uring: use nospec annotation for more indexes Pavel Begunkov
2022-04-07 14:37 ` [PATCH 0/2] two small rsrc infra patches Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-04-07 13:05 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
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 <asml.silence@gmail.com>
---
fs/io_uring.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 714a3797c678..c8993a656c1f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] io_uring: use nospec annotation for more indexes
2022-04-07 13:05 [PATCH 0/2] two small rsrc infra patches Pavel Begunkov
2022-04-07 13:05 ` [PATCH 1/2] io_uring: zero tag on rsrc removal Pavel Begunkov
@ 2022-04-07 13:05 ` Pavel Begunkov
2022-04-07 14:37 ` [PATCH 0/2] two small rsrc infra patches Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-04-07 13:05 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
There are still several places that using pre array_index_nospec()
indexes, fix them up.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
fs/io_uring.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index c8993a656c1f..8b207dbdfb54 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] two small rsrc infra patches
2022-04-07 13:05 [PATCH 0/2] two small rsrc infra patches Pavel Begunkov
2022-04-07 13:05 ` [PATCH 1/2] io_uring: zero tag on rsrc removal Pavel Begunkov
2022-04-07 13:05 ` [PATCH 2/2] io_uring: use nospec annotation for more indexes Pavel Begunkov
@ 2022-04-07 14:37 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-04-07 14:37 UTC (permalink / raw)
To: asml.silence, io-uring
On Thu, 7 Apr 2022 14:05:03 +0100, Pavel Begunkov wrote:
> 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: b5e400c9542fdeca2015d4df7672cbf14d40746f
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-07 14:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 13:05 [PATCH 0/2] two small rsrc infra patches Pavel Begunkov
2022-04-07 13:05 ` [PATCH 1/2] io_uring: zero tag on rsrc removal Pavel Begunkov
2022-04-07 13:05 ` [PATCH 2/2] io_uring: use nospec annotation for more indexes Pavel Begunkov
2022-04-07 14:37 ` [PATCH 0/2] two small rsrc infra patches Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.