public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: syzbot <syzbot+641eec6b7af1f62f2b99@syzkaller.appspotmail.com>,
	io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [io-uring?] memory leak in io_submit_sqes (5)
Date: Mon, 1 Dec 2025 13:16:28 -0700	[thread overview]
Message-ID: <6fcfa902-5d59-4d2a-9fa6-ea59529f6710@kernel.dk> (raw)
In-Reply-To: <692dcb58.a70a0220.2ea503.00b5.GAE@google.com>

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git v6.18

diff --git a/io_uring/poll.c b/io_uring/poll.c
index b9681d0f9f13..5df09e4e958d 100644
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -922,6 +922,11 @@ int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags)
 		goto out;
 	}
 
+	/*
+	 * Set cancel res early, so io_poll_add() can overwrite it, if
+	 * necessary.
+	 */
+	io_req_set_res(preq, -ECANCELED, 0);
 	if (poll_update->update_events || poll_update->update_user_data) {
 		/* only mask one event flags, keep behavior flags */
 		if (poll_update->update_events) {
@@ -936,12 +941,12 @@ int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags)
 
 		ret2 = io_poll_add(preq, issue_flags & ~IO_URING_F_UNLOCKED);
 		/* successfully updated, don't complete poll request */
-		if (!ret2 || ret2 == -EIOCBQUEUED)
+		if (ret2 == IOU_ISSUE_SKIP_COMPLETE)
 			goto out;
 	}
 
-	req_set_fail(preq);
-	io_req_set_res(preq, -ECANCELED, 0);
+	if (preq->cqe.res < 0)
+		req_set_fail(preq);
 	preq->io_task_work.func = io_req_task_complete;
 	io_req_task_work_add(preq);
 out:

-- 
Jens Axboe

  reply	other threads:[~2025-12-01 20:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 17:07 [syzbot] [io-uring?] memory leak in io_submit_sqes (5) syzbot
2025-12-01 20:16 ` Jens Axboe [this message]
2025-12-01 21:00   ` syzbot
2025-12-01 20:36 ` shaurya
2025-12-01 21:24   ` syzbot
2025-12-01 21:29     ` Jens Axboe
2025-12-01 21:31 ` Jens Axboe
2025-12-01 21:52   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6fcfa902-5d59-4d2a-9fa6-ea59529f6710@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+641eec6b7af1f62f2b99@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox