public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring/net: fix sendzc double notif flush
@ 2025-03-22 11:47 Pavel Begunkov
  2025-03-22 14:35 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2025-03-22 11:47 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence

refcount_t: underflow; use-after-free.
WARNING: CPU: 0 PID: 5823 at lib/refcount.c:28 refcount_warn_saturate+0x15a/0x1d0 lib/refcount.c:28
RIP: 0010:refcount_warn_saturate+0x15a/0x1d0 lib/refcount.c:28
Call Trace:
 <TASK>
 io_notif_flush io_uring/notif.h:40 [inline]
 io_send_zc_cleanup+0x121/0x170 io_uring/net.c:1222
 io_clean_op+0x58c/0x9a0 io_uring/io_uring.c:406
 io_free_batch_list io_uring/io_uring.c:1429 [inline]
 __io_submit_flush_completions+0xc16/0xd20 io_uring/io_uring.c:1470
 io_submit_flush_completions io_uring/io_uring.h:159 [inline]

Before the blamed commit, sendzc relied on io_req_msg_cleanup() to clear
REQ_F_NEED_CLEANUP, so after the following snippet the request will
never hit the core io_uring cleanup path.

io_notif_flush();
io_req_msg_cleanup();

The easiest fix is to null the notification. io_send_zc_cleanup() can
still be called after, but it's tolerated.

Reported-by: [email protected]
Tested-by: [email protected]
Fixes: cc34d8330e036 ("io_uring/net: don't clear REQ_F_NEED_CLEANUP unconditionally")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/net.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/net.c b/io_uring/net.c
index a288c75bb92c..50e8a3ccc9de 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1440,6 +1440,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
 	 */
 	if (!(issue_flags & IO_URING_F_UNLOCKED)) {
 		io_notif_flush(zc->notif);
+		zc->notif = NULL;
 		io_req_msg_cleanup(req, 0);
 	}
 	io_req_set_res(req, ret, IORING_CQE_F_MORE);
@@ -1500,6 +1501,7 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
 	 */
 	if (!(issue_flags & IO_URING_F_UNLOCKED)) {
 		io_notif_flush(sr->notif);
+		sr->notif = NULL;
 		io_req_msg_cleanup(req, 0);
 	}
 	io_req_set_res(req, ret, IORING_CQE_F_MORE);
-- 
2.48.1


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

* Re: [PATCH] io_uring/net: fix sendzc double notif flush
  2025-03-22 11:47 [PATCH] io_uring/net: fix sendzc double notif flush Pavel Begunkov
@ 2025-03-22 14:35 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-03-22 14:35 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov


On Sat, 22 Mar 2025 11:47:27 +0000, Pavel Begunkov wrote:
> refcount_t: underflow; use-after-free.
> WARNING: CPU: 0 PID: 5823 at lib/refcount.c:28 refcount_warn_saturate+0x15a/0x1d0 lib/refcount.c:28
> RIP: 0010:refcount_warn_saturate+0x15a/0x1d0 lib/refcount.c:28
> Call Trace:
>  <TASK>
>  io_notif_flush io_uring/notif.h:40 [inline]
>  io_send_zc_cleanup+0x121/0x170 io_uring/net.c:1222
>  io_clean_op+0x58c/0x9a0 io_uring/io_uring.c:406
>  io_free_batch_list io_uring/io_uring.c:1429 [inline]
>  __io_submit_flush_completions+0xc16/0xd20 io_uring/io_uring.c:1470
>  io_submit_flush_completions io_uring/io_uring.h:159 [inline]
> 
> [...]

Applied, thanks!

[1/1] io_uring/net: fix sendzc double notif flush
      (no commit info)

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2025-03-22 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-22 11:47 [PATCH] io_uring/net: fix sendzc double notif flush Pavel Begunkov
2025-03-22 14:35 ` Jens Axboe

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