From: Alexander Lobakin <alobakin@pm.me>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexander Lobakin <alobakin@pm.me>,
Kees Cook <keescook@chromium.org>,
Sami Tolvanen <samitolvanen@google.com>,
Miguel Ojeda <ojeda@kernel.org>, Johan Hovold <johan@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Joe Perches <joe@perches.com>, John Wood <john.wood@gmx.com>,
Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
Hannes Reinecke <hare@suse.de>, Tejun Heo <tj@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] do_mounts: always prefer tmpfs for rootfs when available
Date: Wed, 04 Aug 2021 21:14:02 +0000 [thread overview]
Message-ID: <20210804210627.32421-1-alobakin@pm.me> (raw)
In-Reply-To: <20210702233727.21301-1-alobakin@pm.me>
From: Alexander Lobakin <alobakin@pm.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@pm.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
prev parent reply other threads:[~2021-08-04 21:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 23:44 [PATCH] do_mounts: always prefer tmpfs for rootfs when available Alexander Lobakin
2021-08-04 21:14 ` Alexander Lobakin [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=20210804210627.32421-1-alobakin@pm.me \
--to=alobakin@pm.me \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.de \
--cc=jack@suse.cz \
--cc=joe@perches.com \
--cc=johan@kernel.org \
--cc=john.wood@gmx.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=ojeda@kernel.org \
--cc=samitolvanen@google.com \
--cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).