public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring/rw: fix downgraded mshot read
@ 2024-12-28 17:36 Pavel Begunkov
  2024-12-28 17:39 ` Pavel Begunkov
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2024-12-28 17:36 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]>
---
 io_uring/rw.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/rw.c b/io_uring/rw.c
index b1db4595788b..c212d57df6e5 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 1/1] io_uring/rw: fix downgraded mshot read
  2024-12-28 17:36 [PATCH 1/1] io_uring/rw: fix downgraded mshot read Pavel Begunkov
@ 2024-12-28 17:39 ` Pavel Begunkov
  0 siblings, 0 replies; 2+ messages in thread
From: Pavel Begunkov @ 2024-12-28 17:39 UTC (permalink / raw)
  To: io-uring; +Cc: chase xd

On 12/28/24 17:36, 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.
> 
> 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]>
> ---
>   io_uring/rw.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/io_uring/rw.c b/io_uring/rw.c
> index b1db4595788b..c212d57df6e5 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);

Oops, this one is broken, misses inversion.

-- 
Pavel Begunkov


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-28 17:38 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:36 [PATCH 1/1] io_uring/rw: fix downgraded mshot read Pavel Begunkov
2024-12-28 17:39 ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox