From: Zenghui Yu <zenghui.yu@linux.dev>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: Re: [PATCH] fs: fix ramfs_fs_info leak when rootfs is unmounted
Date: Thu, 29 Oct 2026 17:31:50 +0800 [thread overview]
Message-ID: <e71e3a39-e88d-4e4a-ae4c-51e0783dabe0@linux.dev> (raw)
In-Reply-To: <20261009055546.85279-1-kmehltretter@gmail.com>
On 10/9/26 1:55 PM, Karl Mehltretter wrote:
> When rootfs is a ramfs, for example with root= on the command line, its
> superblock carries a struct ramfs_fs_info from ramfs_init_fs_context().
> ramfs_kill_sb() frees it, but rootfs_fs_type uses kill_anon_super().
>
> Before commit 576ee5dfd459 ("fs: add immutable rootfs") rootfs could not
> be unmounted. Since then prepare_namespace() pivots into the real root
> and unmounts rootfs. When the superblock is destroyed, the structure is
> leaked. kmemleak on an SH7785LCR board:
>
> unreferenced object 0x8100a720 (size 32):
> comm "swapper/0", pid 0, jiffies 4294892299
> backtrace (crc c8bfd23b):
> ...
> ramfs_init_fs_context+0x16/0x48
> rootfs_init_fs_context+0x16/0x2c
> alloc_fs_context+0x98/0x114
> fs_context_for_mount+0x16/0x24
> ...
>
> Call ramfs_kill_sb() when rootfs is a ramfs. tmpfs frees its own data
> in put_super and keeps kill_anon_super().
>
> Fixes: 576ee5dfd459 ("fs: add immutable rootfs")
> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Tested-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
Thanks,
Zenghui
prev parent reply other threads:[~2026-10-29 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 5:55 [PATCH] fs: fix ramfs_fs_info leak when rootfs is unmounted Karl Mehltretter
2026-10-21 11:50 ` Christian Brauner
2026-10-29 9:31 ` Zenghui Yu [this message]
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=e71e3a39-e88d-4e4a-ae4c-51e0783dabe0@linux.dev \
--to=zenghui.yu@linux.dev \
--cc=brauner@kernel.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=jack@suse.cz \
--cc=kmehltretter@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.