From nobody Fri Dec 19 17:21:53 2025 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) (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 855233590D2 for ; Thu, 4 Dec 2025 18:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764872010; cv=none; b=jXY7Ec+3TDj2gu824Fm68gCoJkuYTzjeQhzTtNhYszbtVvPpSl3yS49+fLnOwGqy966A8UBIRqdrbaVQu/1rgPRZqcp8NSrXsq3m//6c5/glIAqMQgl1LFTEWj+zrLJj4pBSiLHFe+X7UbIwcLGka+Y1SxnTZo5S+efKr3sqTOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764872010; c=relaxed/simple; bh=2n8n/CrRkMQeGaIqTUKOtM84mqt2m1JWgo3BQ7O8D2Y=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Oq+pMoSB6QCh9at57WgkBKj8vuTH7WAsCS61pesAM50uEHViR44OAf7npxwOsy7NH40G5vO10v1jj9IxqD64udMyHo7tarw67Yqv0uUE+n9/b3+0yn6j2QUJfe5y/SnIUcPVxwMMYusaG7ma/c5u49Y99jpxJHY6xn1SRq8SrDA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ee.vjti.ac.in; spf=none smtp.mailfrom=ee.vjti.ac.in; dkim=pass (1024-bit key) header.d=vjti.ac.in header.i=@vjti.ac.in header.b=M3wADcFv; arc=none smtp.client-ip=209.85.214.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ee.vjti.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ee.vjti.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vjti.ac.in header.i=@vjti.ac.in header.b="M3wADcFv" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-29555b384acso13072975ad.1 for ; Thu, 04 Dec 2025 10:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vjti.ac.in; s=google; t=1764872007; x=1765476807; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PJvk/IXEAZzbwVmhdAwefI1fSD0T2f/TxkPdH+E3Fkc=; b=M3wADcFvZrxU3adDbJTATHIrCOyHJXadbAianGSwUwco/rW00sePOeFq5yJsVQrjkA nUbpHxETsHEko2NojHSPJYxJDuq5U30umuar4KMkTmeCxk2YbObksOHn8Pq3dVCnotEO Bvgq1FgRNSmsNYDILwd6arY4Al+BhYsPJ7EhA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764872007; x=1765476807; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PJvk/IXEAZzbwVmhdAwefI1fSD0T2f/TxkPdH+E3Fkc=; b=WxpWnHwL/ndynCxR81MuGoxLpkUUXt5/dmt6otqW7fC2GuL9kNemsG35Z3p+VyIjL8 9CTOL1Ql9K4ihcLj68sC7BrPPKCCIZ5hH6nwZ0SjUlfe4OtX9v5dY/9Lo18QM6uzuDQN B9zr64KRTWstsq986Un+XMOZr3xkdsYGVLYmRH5FYJPMheSmz/xGARgC0iqGQtpY87Bp o8NDwVkWD7PQSmeAyYTAtMtNpcrYqm17o1V9Oznk1tA6OCk+iRdJpv1lw2gJA1RoTTcX c+LXGu1bg4I6G/t9xolN57UNWZ9fuBcCOHuwxgZhPETpdCxb9b/v5tzb7BrAHXPa8kvx RNHw== X-Forwarded-Encrypted: i=1; AJvYcCWokBnLjBJktVuNR/h688dnSzpD2sz5VpVEWWNGFkXFArU+oT+BN+/PmJc+DHfdqUYlysYC/fIHDshAbw8=@vger.kernel.org X-Gm-Message-State: AOJu0YwiikaxGS2uqAFa3v5DhpOU1gCjhqcpkoaRn5zNPk6oVSrhhhKc GCZxU9WT3jpko7mG35KS9rIaFD79AO1IUrGD+DoJhyR/e8VlmO9BYFaEc8TnkbGqaHU= X-Gm-Gg: ASbGncs1r4ienxU6bK9oEjACHQEo+OZUTEqdwofB/ikKmgbbglDncnpvQMR20VOAOOS aBUnjYhZtniKyeDvp10Gw4lWw0qH4bog4yMwjujXzMrAYHdLSl/RY2uo8yyYE1DYgd8kdJRbKp9 sqZ8oRhdGNkTKI9O0O1Hth4NCvqXH7uqfV9AXqpxKJaN1SqlCnP98xPZlLqBw0ekL1CAZL3cGOm Yv0HbZAZ4vSb58tTbGo3EwR3KWeSRK6nlxv0/HK3X/ZESMFM1UreqGJavSaT+XWpTJdn5KeJ7v9 spXmHoiqrSw5W98UUHKbtQD9y1LbR7wV+Bl+4TqQ5ChxpVjHL93nAkO8pBaahoELJo4rqPygL77 xFq0zym9px90tDNWDRvKkniDbofHbLK8Dnxucu10UJ4TKN3BkPeVlNSrO3RanNB6EEKkL7u4er9 SqnWwWUa46pVk5Sej8+AitxaVy+mM0s/27WtsrKb7qg3+QjJV3fv6Zv4OHIa987AFl X-Google-Smtp-Source: AGHT+IHW9Dzu/UH+wU35yc2U6yxRXsHH+wAiiYWkaNyB2KGKUs8KlgR+i4pk3Vixmtau8Xk1OhNnpA== X-Received: by 2002:a17:903:245:b0:295:6c26:933b with SMTP id d9443c01a7336-29d682be6a7mr84675015ad.1.1764872006465; Thu, 04 Dec 2025 10:13:26 -0800 (PST) Received: from ranegod-HP-ENVY-x360-Convertible-13-bd0xxx.. ([2409:40c0:1055:766e:b9ed:27c1:5f4a:4f11]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29dae99effasm26060155ad.57.2025.12.04.10.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Dec 2025 10:13:25 -0800 (PST) From: Shaurya Rane To: axboe@kernel.dk, martin.petersen@oracle.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev, david.hunter.linux@gmail.com, khalid@kernel.org, Shaurya Rane , syzbot+527a7e48a3d3d315d862@syzkaller.appspotmail.com, Keith Busch Subject: [PATCH] block: fix memory leak in __blkdev_issue_zero_pages Date: Thu, 4 Dec 2025 23:42:59 +0530 Message-Id: <20251204181259.23864-1-ssrane_b23@ee.vjti.ac.in> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the fatal signal check before bio_alloc() to prevent a memory leak when BLKDEV_ZERO_KILLABLE is set and a fatal signal is pending. Previously, the bio was allocated before checking for a fatal signal. If a signal was pending, the code would break out of the loop without freeing or chaining the just-allocated bio, causing a memory leak. This matches the pattern already used in __blkdev_issue_write_zeroes() where the signal check precedes the allocation. Fixes: bf86bcdb4012 ("blk-lib: check for kill signal in ioctl BLKZEROOUT") Reported-by: syzbot+527a7e48a3d3d315d862@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D527a7e48a3d3d315d862 Signed-off-by: Shaurya Rane Reviewed-by: Keith Busch --- block/blk-lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 3030a772d3aa..352e3c0f8a7d 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -202,13 +202,13 @@ static void __blkdev_issue_zero_pages(struct block_de= vice *bdev, unsigned int nr_vecs =3D __blkdev_sectors_to_bio_pages(nr_sects); struct bio *bio; =20 - bio =3D bio_alloc(bdev, nr_vecs, REQ_OP_WRITE, gfp_mask); - bio->bi_iter.bi_sector =3D sector; - if ((flags & BLKDEV_ZERO_KILLABLE) && fatal_signal_pending(current)) break; =20 + bio =3D bio_alloc(bdev, nr_vecs, REQ_OP_WRITE, gfp_mask); + bio->bi_iter.bi_sector =3D sector; + do { unsigned int len; =20 --=20 2.34.1