public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH 1/1] io_uring: don't re-read iovecs in iopoll_complete
Date: Thu, 25 Feb 2021 13:02:00 +0000	[thread overview]
Message-ID: <3b8aa8f6cfcad71b8a633477932e34232ade68d8.1614257829.git.asml.silence@gmail.com> (raw)

Issuing a request for IO poll and doing actual IO polling might be done
from different syscalls, so userspace's iovec used during submission may
already be gone by the moment of reaping the request and doing reissue
with prep inside is not always safe.

Fail IO poll reissue with -EAGAIN for requests that would need to read
iovec from the userspace. The userspace have to check for it, so it's
fine.

Cc: <[email protected]> # 5.9+
Reported-by: Abaci Robot <[email protected]>
Reported-by: Xiaoguang Wang <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index bf9ad810c621..561c29b20463 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2610,8 +2610,11 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
 		list_del(&req->inflight_entry);
 
 		if (READ_ONCE(req->result) == -EAGAIN) {
+			bool reissue = req->async_data ||
+				!io_op_defs[req->opcode].needs_async_data;
+
 			req->iopoll_completed = 0;
-			if (io_rw_reissue(req))
+			if (reissue && io_rw_reissue(req))
 				continue;
 		}
 
-- 
2.24.0


             reply	other threads:[~2021-02-25 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 13:02 Pavel Begunkov [this message]
2021-02-25 14:58 ` [PATCH 1/1] io_uring: don't re-read iovecs in iopoll_complete 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 \
    --in-reply-to=3b8aa8f6cfcad71b8a633477932e34232ade68d8.1614257829.git.asml.silence@gmail.com \
    [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