[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210804210627.32421-1-alobakin@pm.me>
Date: Wed, 04 Aug 2021 21:14:02 +0000
From: Alexander Lobakin <alobakin@...me>
To: Alexander Viro <viro@...iv.linux.org.uk>
Cc: Alexander Lobakin <alobakin@...me>,
Kees Cook <keescook@...omium.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>,
Johan Hovold <johan@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Joe Perches <joe@...ches.com>, John Wood <john.wood@....com>,
Jens Axboe <axboe@...nel.dk>, Jan Kara <jack@...e.cz>,
Hannes Reinecke <hare@...e.de>, Tejun Heo <tj@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] do_mounts: always prefer tmpfs for rootfs when available
From: Alexander Lobakin <alobakin@...me>
Date: Fri, 02 Jul 2021 23:44:35 +0000
> Inspired by the situation from [0].
>
> The roots of choosing tmpfs/ramfs backend for rootfs go far back
> in history, and it's unclear at all why it was decided to select
> full-blown tmpfs when "root=" is not specified and feature-poor
> ramfs otherwise.
> There are several cases when "root=" is not needed at all to work,
> and it doesn't break anything or make any [negative] sense. On the
> other hand, such separation is rather counter-intuitive and makes
> debugging more difficult.
> Simply always use tmpfs when it's available -- just like devtmpfs
> does [for over a decade].
>
> [0] https://lore.kernel.org/kernel-hardening/20210701234807.50453-1-alobakin@pm.me/
>
> Signed-off-by: Alexander Lobakin <alobakin@...me>
Ping?
> ---
> fs/namespace.c | 2 --
> include/linux/init.h | 1 -
> init/do_mounts.c | 26 +++++++-------------------
> 3 files changed, 7 insertions(+), 22 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index ab4174a3c802..310ab44fdbe7 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -17,7 +17,6 @@
> #include <linux/security.h>
> #include <linux/cred.h>
> #include <linux/idr.h>
> -#include <linux/init.h> /* init_rootfs */
> #include <linux/fs_struct.h> /* get_fs_root et.al. */
> #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
> #include <linux/file.h>
> @@ -4248,7 +4247,6 @@ void __init mnt_init(void)
> if (!fs_kobj)
> printk(KERN_WARNING "%s: kobj create error\n", __func__);
> shmem_init();
> - init_rootfs();
> init_mount_tree();
> }
>
> diff --git a/include/linux/init.h b/include/linux/init.h
> index d82b4b2e1d25..10839922a1d3 100644
> --- a/include/linux/init.h
> +++ b/include/linux/init.h
> @@ -148,7 +148,6 @@ extern unsigned int reset_devices;
> /* used by init/main.c */
> void setup_arch(char **);
> void prepare_namespace(void);
> -void __init init_rootfs(void);
> extern struct file_system_type rootfs_fs_type;
>
> #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
> diff --git a/init/do_mounts.c b/init/do_mounts.c
> index 74aede860de7..c00b05015a66 100644
> --- a/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -611,24 +611,12 @@ void __init prepare_namespace(void)
> init_chroot(".");
> }
>
> -static bool is_tmpfs;
> -static int rootfs_init_fs_context(struct fs_context *fc)
> -{
> - if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs)
> - return shmem_init_fs_context(fc);
> -
> - return ramfs_init_fs_context(fc);
> -}
> -
> struct file_system_type rootfs_fs_type = {
> - .name = "rootfs",
> - .init_fs_context = rootfs_init_fs_context,
> - .kill_sb = kill_litter_super,
> + .name = "rootfs",
> +#ifdef CONFIG_TMPFS
> + .init_fs_context = shmem_init_fs_context,
> +#else
> + .init_fs_context = ramfs_init_fs_context,
> +#endif
> + .kill_sb = kill_litter_super,
> };
> -
> -void __init init_rootfs(void)
> -{
> - if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
> - (!root_fs_names || strstr(root_fs_names, "tmpfs")))
> - is_tmpfs = true;
> -}
> --
> 2.32.0
Thanks,
Al
Powered by blists - more mailing lists