Re: [PATCH v2] Fix regression due to "fs: move binfmt_misc sysctl to its own file"

From: Tong Zhang
Date: Sun Feb 13 2022 - 16:10:58 EST


On Sun, Feb 13, 2022 at 7:34 AM Ido Schimmel <idosch@xxxxxxxxxx> wrote:
>
> On Wed, Feb 09, 2022 at 08:49:20AM +0100, Domenico Andreoli wrote:
> > fs/binfmt_misc.c | 6 +-----
> > fs/file_table.c | 2 ++
> > 2 files changed, 3 insertions(+), 5 deletions(-)
> >
> > Index: b/fs/binfmt_misc.c
> > ===================================================================
> > --- a/fs/binfmt_misc.c
> > +++ b/fs/binfmt_misc.c
> > @@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ
> > };
> > MODULE_ALIAS_FS("binfmt_misc");
> >
> > -static struct ctl_table_header *binfmt_misc_header;
> > -
> > static int __init init_misc_binfmt(void)
> > {
> > int err = register_filesystem(&bm_fs_type);
> > if (!err)
> > insert_binfmt(&misc_format);
> > - binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
> > - return 0;
> > + return err;
> > }
> >
> > static void __exit exit_misc_binfmt(void)
> > {
> > - unregister_sysctl_table(binfmt_misc_header);
> > unregister_binfmt(&misc_format);
> > unregister_filesystem(&bm_fs_type);
> > }
> > Index: b/fs/file_table.c
> > ===================================================================
> > --- a/fs/file_table.c
> > +++ b/fs/file_table.c
> > @@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[
> > static int __init init_fs_stat_sysctls(void)
> > {
> > register_sysctl_init("fs", fs_stat_sysctls);
> > + if (IS_ENABLED(CONFIG_BINFMT_MISC))
> > + register_sysctl_mount_point("fs/binfmt_misc");
>
> Hi,
>
> kmemleak complains about this:
>
> # cat /sys/kernel/debug/kmemleak
> unreferenced object 0xffff8881045fea88 (size 96):
> comm "swapper/0", pid 1, jiffies 4294669355 (age 167.804s)
> hex dump (first 32 bytes):
> e0 c8 07 88 ff ff ff ff 00 00 00 00 01 00 00 00 ................
> 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace:
> [<ffffffff81d11637>] __register_sysctl_table+0x117/0x1150
> [<ffffffff86c3600f>] init_fs_stat_sysctls+0x30/0x33
> [<ffffffff81002558>] do_one_initcall+0x108/0x690
> [<ffffffff86bca8bd>] kernel_init_freeable+0x45a/0x4de
> [<ffffffff83e0757f>] kernel_init+0x1f/0x220
> [<ffffffff810048cf>] ret_from_fork+0x1f/0x30
>
> > return 0;
> > }
> > fs_initcall(init_fs_stat_sysctls);
> >

Hi Ido,
Thanks for the report. This is a known issue. The fix is proposed here.
https://lore.kernel.org/all/YgRbEG21AUrLSFKX@xxxxxxxxxxxxxxxxxxxxxx/

Thanks,
- Tong