From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C72B395ADD for ; Thu, 20 Aug 2026 18:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787252202; cv=none; b=Ae3S0S317jNbJ29RWUpg0VlYlkwfhdgwagBeEx1zqL1F1KHqv0Pbpr+MyCOAspsceVOMpGklxqvoRIFkE9rTRiF6VoUFx+aLxAch5gnm0bHHgYlagvuLAahpPR73SrGQgVz2YF1FkWqaUFkwWH7gEAcsiUFAGTr2i51uOAdWKjU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787252202; c=relaxed/simple; bh=mesWg9i7Pr/sSuIGx5GPGHew6O9XxQdEW6+uh1a/PH4=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To:Cc: Content-Type; b=gFGHJ+mwqaOPR64i7MF2IQFBhJSz+XC8qG5PMbbDP4mLgUEgB/dZjwZljaFumgN5yl6Qjhi08eHQpRTIm5O05Fo+GVZ5O+LqGtClBlw4GUBOa/OeXg+FufJC4WQSA5bQDKBdoa3FdTS/beg0m1CQliTPn+q9Einvz+Mpitt6tHg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-6b12d7e6b0aso230314eaf.3 for ; Thu, 20 Aug 2026 11:56:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787252198; x=1787856998; h=content-type:cc:to:from:subject:message-id:in-reply-to:date :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=pBFqiBHmofgG+eXPLrOcoNQHRSu6BoQpnBJ5ylIeG0s=; b=q8C+L+pYOhfAoqfMAnobN+Lmi2y8SkVpHWQM9XgbdbMHhb5v0zMj/mUkZrfjuVpWKd ftKozjthwq0VvBarfe2SX3ReSCbYWbpGA6MVTEGWTIjjWrya5E89RjKvsJ6wg8zptdLd mT2LssBiUYxAms5lPXfPfFDpTvoC747zifDtRmGbHssYWJTsEZFMBDW/VCKDoWe2quYy PJGOK86YUKhnkZqjRguVYD49J3tZxMeKxQVJZu8ij4wfIIw0AYm/b10oz3zgaQVQRDex LrfCI91W3gmsVjH8Sfxt/xg7U78T1UatvRuJPzXGYHrSXHK0Y2AlOx9QSlDno84gSnPQ ynRQ== X-Forwarded-Encrypted: i=1; AHgh+RpiW2rHp/cNqO6e1MQtR4vy7i+Czp6LGkvv2elPG6rfJSQjEu4/FBBo572fNDryWQAQdhAv+7s9gs/cZAw=@vger.kernel.org X-Gm-Message-State: AOJu0YyFL51gaWtKWdSu32uPNoDlu0IbxLTEAKuM2HTmHgeVlqYzO+/M gm3A85EF04F5x/BtjnwoaOQJRBUgBDEPUotSPkSGETMzGJ+lmmM3wnVyVT4qMohZjBjM0phaYO0 a1IK33o3+alJzlHrKZ728I5wmPqkNMeVNCD2YYJ4+vz5IoVGo3PbFxIAT2gI= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:3407:20b0:6b1:3417:548b with SMTP id 006d021491bc7-6b1593f0db1mr694031eaf.24.1787252197854; Thu, 20 Aug 2026 11:56:37 -0700 (PDT) Date: Thu, 20 Aug 2026 11:56:37 -0700 In-Reply-To: <165bc4ff-ec69-4058-b6a2-3db02410ce58@gmail.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a874de5.ae6ddae5.3da009.001e.GAE@google.com> Subject: Re: [RFC PATCH] io_uring/cmd: don't skip completion for a non-armed multishot uring_cmd From: syzbot To: vasilisalmpanis@gmail.com Cc: axboe@kernel.dk, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, ming.lei@redhat.com, vasilisalmpanis@gmail.com, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" > Hi everyone, > > Just a gentle ping on this patch. > > The issue is syzbot-reproduced and the proposed fix has been run with > #syz test. unknown command "test." > The patch addresses the leak in the core |io_uring_cmd()|path rather than > relying on individual providers to handle |IORING_URING_CMD_MULTISHOT|. > > Could someone take a look when you get a chance? > > Thanks, > Vasileios > > > On 8/11/26 10:42 PM, Vasileios Almpanis wrote: >> io_uring_cmd() treats any uring_cmd carrying IORING_URING_CMD_MULTISHOT >> that returns >= 0 as "multishot armed, completion deferred" and returns >> IOU_ISSUE_SKIP_COMPLETE, expecting the provider to complete the request >> later. But the flag is user-controlled and validated only against buffer >> select, not against provider capability. A ->uring_cmd() handler that >> does not implement multishot and returns a normal >= 0 result then has >> its request skipped and never completed, leaking the io_kiocb and its >> io_async_cmd: >> >> BUG: memory leak >> unreferenced object (size 248): >> kmem_cache_alloc_bulk_noprof+0x272/0x3f0 >> __io_alloc_req_refill+0x4a/0x150 >> io_submit_sqes.cold+0x16e/0x20b >> __do_sys_io_uring_enter+0x56d/0xd60 >> >> syzbot hit this via ublk UBLK_U_CMD_ADD_DEV, but it is kernel-wide: the >> same leak reproduces with SOCKET_URING_OP_SIOCINQ on any socket fd, which >> returns the queued byte count and never inspects cmd->flags. No in-tree >> provider of multishot actually returns >= 0. Both io_cmd_poll_multishot() >> and ublk_handle_batch_fetch_cmd return -EIOCBQUEUED, >> >> Only skip completion when the command is really multishot, i.e. >> REQ_F_APOLL_MULTISHOT is set. Otherwise fall through and complete the >> request normally with its result. >> >> Fixes: 620a50c92700 ("io_uring: uring_cmd: add multishot support") >> Reported-by: syzbot+a4ccdd7ebf452e4d4701@syzkaller.appspotmail.com >> Closes: https://syzkaller.appspot.com/bug?extid=a4ccdd7ebf452e4d4701 >> Tested-by: syzbot+a4ccdd7ebf452e4d4701@syzkaller.appspotmail.com >> Signed-off-by: Vasileios Almpanis >> --- >> Questions / Notes: >> - I put this in the core io_uring_cmd() rather than in provider specific >> code because the leak is independent of the provider. From my research >> so far no ->uring_cmd() rejects IORING_URING_CMD_MULTISHOT, they just >> ignore it. The flag is only validated against buffer-select in >> io_uring_cmd_prep(). So any handler that returns a plain >= 0 result >> with the user-set flag leaks. >> - Instead of checking if it has been really armed should we just drop >> the >= 0 check? The in-tree code that supports multishot returns >> -EIOCBQUEUED from what I have seen so far. >> --- >> io_uring/uring_cmd.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c >> index c14c22cff49e..a2899a852879 100644 >> --- a/io_uring/uring_cmd.c >> +++ b/io_uring/uring_cmd.c >> @@ -269,7 +269,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) >> } >> >> ret = file->f_op->uring_cmd(ioucmd, issue_flags); >> - if (ioucmd->flags & IORING_URING_CMD_MULTISHOT) { >> + if ((ioucmd->flags & IORING_URING_CMD_MULTISHOT) && >> + (req->flags & REQ_F_APOLL_MULTISHOT)) { >> if (ret >= 0) >> return IOU_ISSUE_SKIP_COMPLETE; >> } >> >> --- >> base-commit: d58772d8520c7ef247c4b95c9bd76d3a25da9ff5 >> change-id: 20260811-io_uring-169337c74617 >> >> Best regards, >> -- >> Vasileios Almpanis >>