* [PATCH v2 1/1] io_uring/rw: fix downgraded mshot read
@ 2024-12-28 17:44 Pavel Begunkov
2024-12-28 20:14 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2024-12-28 17:44 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, chase xd
The iowq path can downgrade a multishot request to the oneshot mode,
however io_read_mshot() doesn't handle that and would still post
multiple CQEs. That's not allowed, because io_req_post_cqe() requires
stricter context requirements.
The described can only happen with pollable files that don't support
FMODE_NOWAIT, which is an odd combination, so if even allowed it should
be fairly rare.
Cc: [email protected]
Reported-by: chase xd <[email protected]>
Fixes: bee1d5becdf5b ("io_uring: disable io-wq execution of multishot NOWAIT requests")
Signed-off-by: Pavel Begunkov <[email protected]>
---
v2: inverse the if condition
io_uring/rw.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index b1db4595788b..be176f4828e2 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -1066,6 +1066,8 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
io_kbuf_recycle(req, issue_flags);
if (ret < 0)
req_set_fail(req);
+ } else if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {
+ cflags = io_put_kbuf(req, ret, issue_flags);
} else {
/*
* Any successful return value will keep the multishot read
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] io_uring/rw: fix downgraded mshot read
2024-12-28 17:44 [PATCH v2 1/1] io_uring/rw: fix downgraded mshot read Pavel Begunkov
@ 2024-12-28 20:14 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-12-28 20:14 UTC (permalink / raw)
To: io-uring, Pavel Begunkov; +Cc: chase xd
On Sat, 28 Dec 2024 17:44:52 +0000, Pavel Begunkov wrote:
> The iowq path can downgrade a multishot request to the oneshot mode,
> however io_read_mshot() doesn't handle that and would still post
> multiple CQEs. That's not allowed, because io_req_post_cqe() requires
> stricter context requirements.
>
> The described can only happen with pollable files that don't support
> FMODE_NOWAIT, which is an odd combination, so if even allowed it should
> be fairly rare.
>
> [...]
Applied, thanks!
[1/1] io_uring/rw: fix downgraded mshot read
commit: 38fc96a58ce40257aec79b32e9b310c86907c63c
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-28 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-28 17:44 [PATCH v2 1/1] io_uring/rw: fix downgraded mshot read Pavel Begunkov
2024-12-28 20:14 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox