Skip to content

Commit 9752dd3

Browse files
isilencegregkh
authored andcommitted
io_uring/net: fix sendzc double notif flush
commit 67c007d upstream. 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: syzbot+cf285a028ffba71b2ef5@syzkaller.appspotmail.com Tested-by: syzbot+cf285a028ffba71b2ef5@syzkaller.appspotmail.com Fixes: cc34d83 ("io_uring/net: don't clear REQ_F_NEED_CLEANUP unconditionally") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/e1306007458b8891c88c4f20c966a17595f766b0.1742643795.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f6a6721 commit 9752dd3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

io_uring/net.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
14391439
*/
14401440
if (!(issue_flags & IO_URING_F_UNLOCKED)) {
14411441
io_notif_flush(zc->notif);
1442+
zc->notif = NULL;
14421443
io_req_msg_cleanup(req, 0);
14431444
}
14441445
io_req_set_res(req, ret, IORING_CQE_F_MORE);
@@ -1499,6 +1500,7 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
14991500
*/
15001501
if (!(issue_flags & IO_URING_F_UNLOCKED)) {
15011502
io_notif_flush(sr->notif);
1503+
sr->notif = NULL;
15021504
io_req_msg_cleanup(req, 0);
15031505
}
15041506
io_req_set_res(req, ret, IORING_CQE_F_MORE);

0 commit comments

Comments
 (0)