From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Breno Leitao <leitao@debian.org>, Ard Biesheuvel <ardb@kernel.org>
Cc: Jeremy Kerr <jk@ozlabs.org>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH] efivarfs: Suppress false-positive kmemleak warning for sfi
Date: Wed, 16 Jul 2025 08:31:04 -0400 [thread overview]
Message-ID: <a3d063f4b0ccaad7595938ea0dca016872882f0d.camel@HansenPartnership.com> (raw)
In-Reply-To: <rvlw467lzx5yx3sl56u3xcc2hhhn3vj2fu7msg3e5o4giwtkcb@oomdafhhnqcv>
On Wed, 2025-07-16 at 04:45 -0700, Breno Leitao wrote:
> On Wed, Jul 16, 2025 at 10:41:24AM +1000, Ard Biesheuvel wrote:
> > On Tue, 15 Jul 2025 at 19:31, Breno Leitao <leitao@debian.org>
> > wrote:
> > >
> > > When kmemleak is enabled, it incorrectly reports the sfi
> > > structure allocated during efivarfs_init_fs_context() as leaked:
> > >
> > > unreferenced object 0xffff888146250b80 (size 64):
> > > __kmalloc_cache_noprof
> > > efivarfs_init_fs_context
> > > ...
> > >
> > > On module unload, this object is freed in efivarfs_kill_sb(),
> > > confirming no actual leak. Also, kfree(sfi) is called at
> > > efivarfs_kill_sb(). I am not able to explain why kmemleak
> > > detected it as a leak. To silence this false-positive, mark the
> > > sfi allocation as ignored by kmemleak right after allocation.
> > >
> > > This ensures clearer leak diagnostics for this allocation path.
> > >
> >
> > Can you provide a reproducer? x86 defconfig with kmemleak enabled
> > does not show this behavior.
>
> I see this problem all the time when mounting efivars. This is the
> config I am using: https://pastebin.com/i21Yv0jt
Actually, there is a way this could be happening: to process the
options, we have to allocate sfi early when the fs_context is
initialized, but it is actually a property of the superblock and is
freed when the superblock is killed. If we got a situation where
something did a final put of the fs context before we get to fill_super
(which is where the handover happens) we would leak sfi's. This would
have to be on an error leg I presume (or possibly a reconfigure looking
at the code).
If the theory is correct, the leak is genuine and we need to implement
.free in efivarfs_context_ops to fix it.
Regards,
James
next prev parent reply other threads:[~2025-07-16 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 9:28 Breno Leitao
2025-07-16 0:41 ` Ard Biesheuvel
2025-07-16 11:45 ` Breno Leitao
2025-07-16 12:31 ` James Bottomley [this message]
2025-07-16 13:09 ` James Bottomley
2025-07-16 13:16 ` Breno Leitao
2025-07-16 13:26 ` James Bottomley
2025-07-16 14:30 ` Breno Leitao
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=a3d063f4b0ccaad7595938ea0dca016872882f0d.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=jk@ozlabs.org \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®