From: Jens Axboe <[email protected]>
To: Dylan Yudaken <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH 1/2] io_uring: do not allow multishot read to set addr or len
Date: Mon, 6 Nov 2023 07:32:21 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 11/5/23 3:30 PM, Dylan Yudaken wrote:
> For addr: this field is not used, since buffer select is forced. But by forcing
> it to be zero it leaves open future uses of the field.
>
> len is actually usable, you could imagine that you want to receive
> multishot up to a certain length.
> However right now this is not how it is implemented, and it seems
> safer to force this to be zero.
>
> Fixes: fc68fcda0491 ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT")
> Signed-off-by: Dylan Yudaken <[email protected]>
> ---
> io_uring/rw.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/io_uring/rw.c b/io_uring/rw.c
> index 1c76de483ef6..ea86498d8769 100644
> --- a/io_uring/rw.c
> +++ b/io_uring/rw.c
> @@ -111,6 +111,13 @@ int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe)
> rw->len = READ_ONCE(sqe->len);
> rw->flags = READ_ONCE(sqe->rw_flags);
>
> + if (req->opcode == IORING_OP_READ_MULTISHOT) {
> + if (rw->addr)
> + return -EINVAL;
> + if (rw->len)
> + return -EINVAL;
> + }
Should we just put these in io_read_mshot_prep() instead? Ala the below.
In general I think it'd be nice to have a core prep_rw, and then each
variant will have its own prep. Then we can get away from random opcode
checking in there.
I do agree with the change in general, just think we can tweak it a bit
to make it a bit cleaner.
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 1c76de483ef6..635a1bf5df70 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -129,6 +129,7 @@ int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe)
*/
int io_read_mshot_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
+ struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
int ret;
/* must be used with provided buffers */
@@ -139,6 +140,9 @@ int io_read_mshot_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (unlikely(ret))
return ret;
+ if (rw->addr || rw->len)
+ return -EINVAL;
+
req->flags |= REQ_F_APOLL_MULTISHOT;
return 0;
}
--
Jens Axboe
next prev parent reply other threads:[~2023-11-06 14:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 22:30 [PATCH 0/2] io_uring: mshot read fix for buffer size changes Dylan Yudaken
2023-11-05 22:30 ` [PATCH 1/2] io_uring: do not allow multishot read to set addr or len Dylan Yudaken
2023-11-06 14:32 ` Jens Axboe [this message]
2023-11-06 14:51 ` Jens Axboe
2023-11-06 15:31 ` Dylan Yudaken
2023-11-05 22:30 ` [PATCH 2/2] io_uring: do not clamp read length for multishot read Dylan Yudaken
2023-11-06 14:46 ` Jens Axboe
2023-11-06 15:33 ` Dylan Yudaken
2023-11-06 15:46 ` Jens Axboe
2023-11-06 17:56 ` Jens Axboe
2023-11-06 20:35 ` [PATCH 0/2] io_uring: mshot read fix for buffer size changes Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox