lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXHJpRioZD7aUJnkMLWkiTmQ_Nr6MNcSYR0adeLdjf5BrA@mail.gmail.com>
Date: Wed, 16 Jul 2025 10:41:24 +1000
From: Ard Biesheuvel <ardb@...nel.org>
To: Breno Leitao <leitao@...ian.org>
Cc: Jeremy Kerr <jk@...abs.org>, linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org, 
	kernel-team@...a.com
Subject: Re: [PATCH] efivarfs: Suppress false-positive kmemleak warning for sfi

On Tue, 15 Jul 2025 at 19:31, Breno Leitao <leitao@...ian.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.

In any case, just silencing the diagnostic is not a great way to deal
with this imho.


> Signed-off-by: Breno Leitao <leitao@...ian.org>
> ---
>  fs/efivarfs/super.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
> index c900d98bf4945..5f867ad2005ae 100644
> --- a/fs/efivarfs/super.c
> +++ b/fs/efivarfs/super.c
> @@ -19,6 +19,7 @@
>  #include <linux/notifier.h>
>  #include <linux/printk.h>
>  #include <linux/namei.h>
> +#include <linux/kmemleak.h>
>
>  #include "internal.h"
>  #include "../internal.h"
> @@ -498,6 +499,7 @@ static int efivarfs_init_fs_context(struct fs_context *fc)
>         if (!sfi)
>                 return -ENOMEM;
>
> +       kmemleak_ignore(sfi);
>         sfi->mount_opts.uid = GLOBAL_ROOT_UID;
>         sfi->mount_opts.gid = GLOBAL_ROOT_GID;
>
>
> ---
> base-commit: 8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2
> change-id: 20250714-kmemleak_efi-bedfe48a304d
>
> Best regards,
> --
> Breno Leitao <leitao@...ian.org>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ