2022-02-09 12:52:40

by Tong Zhang

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

On Tue, Feb 8, 2022 at 11:49 PM Domenico Andreoli
<[email protected]> wrote:
>
> Commit 3ba442d5331f did not go unnoticed, binfmt-support stopped to
> work on my Debian system since v5.17-rc2 (did not check with -rc1).
>
> The existance of the /proc/sys/fs/binfmt_misc is a precondition for
> attempting to mount the binfmt_misc fs, which in turn triggers the
> autoload of the binfmt_misc module. Without it, no module is loaded
> and no binfmt is available at boot.
>
> Building as built-in or manually loading the module and mounting the fs
> works fine, it's therefore only a matter of interaction with user-space.
> I could try to improve the Debian systemd configuration but I can't
> say anything about the other distributions.
>
> This patch restores a working system right after boot.
>
> v2:
> - move creation of fs/binfmt_misc to fs/file_table.c
> - use IS_ENABLED() to conditionally create it
>
> Fixes: 3ba442d5331f ("fs: move binfmt_misc sysctl to its own file")
> Signed-off-by: Domenico Andreoli <[email protected]>
> Cc: Al Viro <[email protected]>
> Cc: Amir Goldstein <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Andy Shevchenko <[email protected]>
> Cc: Antti Palosaari <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Benjamin Herrenschmidt <[email protected]>
> Cc: Benjamin LaHaise <[email protected]>
> Cc: Clemens Ladisch <[email protected]>
> Cc: David Airlie <[email protected]>
> Cc: Douglas Gilbert <[email protected]>
> Cc: Eric Biederman <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Iurii Zaikin <[email protected]>
> Cc: James E.J. Bottomley <[email protected]>
> Cc: Jan Kara <[email protected]>
> Cc: Jani Nikula <[email protected]>
> Cc: Jani Nikula <[email protected]>
> Cc: Joel Becker <[email protected]>
> Cc: John Ogness <[email protected]>
> Cc: Joonas Lahtinen <[email protected]>
> Cc: Joseph Qi <[email protected]>
> Cc: Julia Lawall <[email protected]>
> Cc: Kees Cook <[email protected]>
> Cc: Lukas Middendorf <[email protected]>
> Cc: Mark Fasheh <[email protected]>
> Cc: Martin K. Petersen <[email protected]>
> Cc: Paul Turner <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Petr Mladek <[email protected]>
> Cc: Phillip Potter <[email protected]>
> Cc: Qing Wang <[email protected]>
> Cc: "Rafael J. Wysocki" <[email protected]>
> Cc: Rodrigo Vivi <[email protected]>
> Cc: Sebastian Reichel <[email protected]>
> Cc: Sergey Senozhatsky <[email protected]>
> Cc: Stephen Kitt <[email protected]>
> Cc: Steven Rostedt (VMware) <[email protected]>
> Cc: Suren Baghdasaryan <[email protected]>
> Cc: Tetsuo Handa <[email protected]>
> Cc: "Theodore Ts'o" <[email protected]>
> Cc: Xiaoming Ni <[email protected]>
>
> ---
> 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");
> return 0;
> }
> fs_initcall(init_fs_stat_sysctls);

Looks good
Thanks!

Reviewed-by: Tong Zhang <[email protected]>