* [PATCH 1/1] io_uring: don't re-read iovecs in iopoll_complete
@ 2021-02-25 13:02 Pavel Begunkov
2021-02-25 14:58 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-02-25 13:02 UTC (permalink / raw)
To: Jens Axboe, io-uring; +Cc: xiaoguang.wang, asml.silence
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] io_uring: don't re-read iovecs in iopoll_complete
2021-02-25 13:02 [PATCH 1/1] io_uring: don't re-read iovecs in iopoll_complete Pavel Begunkov
@ 2021-02-25 14:58 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-02-25 14:58 UTC (permalink / raw)
To: Pavel Begunkov, io-uring; +Cc: xiaoguang.wang
On 2/25/21 6:02 AM, Pavel Begunkov wrote:
> 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.
That looks fine, we can't be off the submit path at that point, so
should get -EAGAIN if we don't have the state we need.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-25 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-25 13:02 [PATCH 1/1] io_uring: don't re-read iovecs in iopoll_complete Pavel Begunkov
2021-02-25 14:58 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox