From: Sasha Levin <sashal@kernel.org>
To: viro@zeniv.linux.org.uk, brauner@kernel.org
Cc: jack@suse.cz, axboe@kernel.dk, changfengnan@bytedance.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH] buffer: fix kmemleak false positive in submit_bh_wbc
Date: Tue, 24 Feb 2026 14:06:37 -0500 [thread overview]
Message-ID: <20260224190637.3279019-1-sashal@kernel.org> (raw)
Bios allocated in submit_bh_wbc are properly freed via their end_io
handler. Since commit 48f22f80938d, bio_put() caches them in a per-CPU
bio cache for reuse rather than freeing them back to the mempool.
While cached bios are reachable by kmemleak via the per-CPU cache
pointers, once recycled for new I/O they are only referenced by block
layer internals that kmemleak does not scan, causing false positive
leak reports.
Mark the bio allocation with kmemleak_not_leak() to suppress the false
positive.
Fixes: 48f22f80938d ("block: enable per-cpu bio cache by default")
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/buffer.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/buffer.c b/fs/buffer.c
index 22b43642ba574..c298df6c7f8c6 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -49,6 +49,7 @@
#include <linux/sched/mm.h>
#include <trace/events/block.h>
#include <linux/fscrypt.h>
+#include <linux/kmemleak.h>
#include <linux/fsverity.h>
#include <linux/sched/isolation.h>
@@ -2799,6 +2800,7 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
opf |= REQ_PRIO;
bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
+ kmemleak_not_leak(bio);
fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO);
--
2.51.0
next reply other threads:[~2026-02-24 19:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 19:06 Sasha Levin [this message]
2026-02-24 21:57 ` Jens Axboe
2026-02-25 13:25 ` Sasha Levin
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=20260224190637.3279019-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=changfengnan@bytedance.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®