From: shaurya <ssranevjti@gmail.com>
To: syzbot+527a7e48a3d3d315d862@syzkaller.appspotmail.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [block?] [udf?] memory leak in __blkdev_issue_zero_pages
Date: Thu, 4 Dec 2025 21:42:38 +0530 [thread overview]
Message-ID: <23fde58b-ef8f-4420-b0a8-5ae87dfe0bc4@gmail.com> (raw)
In-Reply-To: <6931abe7.a70a0220.2ea503.00e0.GAE@google.com>
[-- Attachment #1: Type: text/plain, Size: 84 bytes --]
#syz test:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
[-- Attachment #2: 0001-block-fix-memory-leak-in-__blkdev_issue_zero_pages.patch --]
[-- Type: text/x-patch, Size: 1463 bytes --]
From 79fe005d08f4f81f422a371fd7d4d3cd2580a65f Mon Sep 17 00:00:00 2001
From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
Date: Thu, 4 Dec 2025 21:38:51 +0530
Subject: [PATCH] block: fix memory leak in __blkdev_issue_zero_pages
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.
Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
---
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_device *bdev,
unsigned int nr_vecs = __blkdev_sectors_to_bio_pages(nr_sects);
struct bio *bio;
- bio = bio_alloc(bdev, nr_vecs, REQ_OP_WRITE, gfp_mask);
- bio->bi_iter.bi_sector = sector;
-
if ((flags & BLKDEV_ZERO_KILLABLE) &&
fatal_signal_pending(current))
break;
+ bio = bio_alloc(bdev, nr_vecs, REQ_OP_WRITE, gfp_mask);
+ bio->bi_iter.bi_sector = sector;
+
do {
unsigned int len;
--
2.34.1
next prev parent reply other threads:[~2025-12-04 16:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 15:42 [syzbot] [block?] [udf?] memory leak in __blkdev_issue_zero_pages syzbot
2025-12-04 16:12 ` shaurya [this message]
2025-12-04 17:28 ` syzbot
2025-12-04 17:55 ` Keith Busch
2025-12-05 8:15 ` Hannes Reinecke
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=23fde58b-ef8f-4420-b0a8-5ae87dfe0bc4@gmail.com \
--to=ssranevjti@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+527a7e48a3d3d315d862@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