public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dylan Yudaken <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
	Dylan Yudaken <[email protected]>
Subject: [PATCH 2/2] io_uring: do not clamp read length for multishot read
Date: Sun,  5 Nov 2023 22:30:08 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

When doing a multishot read, the code path reuses the old read
paths. However this breaks an assumption built into those paths,
namely that struct io_rw::len is available for reuse by __io_import_iovec.

For multishot this results in len being set for the first receive
call, and then subsequent calls are clamped to that buffer length incorrectly.

Fixes: fc68fcda0491 ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT")
Signed-off-by: Dylan Yudaken <[email protected]>
---
 io_uring/rw.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/rw.c b/io_uring/rw.c
index ea86498d8769..b7f7fbc28032 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -417,6 +417,8 @@ static struct iovec *__io_import_iovec(int ddir, struct io_kiocb *req,
 
 	if (!io_issue_defs[opcode].vectored || req->flags & REQ_F_BUFFER_SELECT) {
 		if (io_do_buffer_select(req)) {
+			if (opcode == IORING_OP_READ_MULTISHOT)
+				sqe_len = 0;
 			buf = io_buffer_select(req, &sqe_len, issue_flags);
 			if (!buf)
 				return ERR_PTR(-ENOBUFS);
-- 
2.41.0


  parent reply	other threads:[~2023-11-05 22:30 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
2023-11-06 14:51     ` Jens Axboe
2023-11-06 15:31       ` Dylan Yudaken
2023-11-05 22:30 ` Dylan Yudaken [this message]
2023-11-06 14:46   ` [PATCH 2/2] io_uring: do not clamp read length for multishot read 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