Linux filesystem development
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Alexander Mikhalitsyn <alex@amutable.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Josef Bacik <josef@toxicpanda.com>,
	Christian Brauner <brauner@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	David Howells <dhowells@redhat.com>, Jan Kara <jack@suse.cz>,
	Serge Hallyn <sergeh@kernel.org>, Kees Cook <kees@kernel.org>,
	Paul Moore <paul@paul-moore.com>,
	linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 00/13] Namespace for namespace roots
Date: Fri, 20 Nov 2026 15:13:08 +0200	[thread overview]
Message-ID: <awBHZO2VwWyJzvBN@kernel.org> (raw)
In-Reply-To: <c301fff20a4920fcd3baa31dda2e31ad99c93436.camel@amutable.com>

On Fri, Nov 20, 2026 at 01:32:57PM +0100, Alexander Mikhalitsyn wrote:
> On Thu, 2026-11-19 at 15:27 -0800, Andy Lutomirski wrote:
> > On Thu, Nov 19, 2026 at 2:50 PM Andy Lutomirski <luto@amacapital.net>
> > wrote:
> > > 
> > > On Thu, Nov 19, 2026 at 9:30 AM Josef Bacik <josef@toxicpanda.com>
> > > wrote:
> > > > 
> > > > On Wed, Nov 18, 2026 at 9:46 AM Andy Lutomirski
> > > > <luto@amacapital.net> wrote:
> > > > > cells: The dance where I create an anonymous mountns, mount
> > > > > stuff into
> > > > > it, and then attach it to the cell is cute.  But I think the
> > > > > userns
> > > > > interaction is wrong: you are making me assemble all the mounts
> > > > > in
> > > > > *my* userns and then clone the entire tree into a fresh, non-
> > > > > anonymous
> > > > > mountns bound to the current userns.  And that clone operation
> > > > > is not
> > > > > free and serves no actual practical purpose.
> > > > 
> > > > The copy buys us nothing, agreed.  That's just what the mount API
> > > > gives
> > > > me to work with today, it's not something cells wants.  If I
> > > > could make
> > > > an empty mount namespace and fill it by fd I'd use that, the
> > > > "root" slot
> > > > takes a mount namespace fd already.  Extending the API for that
> > > > makes
> > > > sense to me on its own.
> > > > 
> > > > The mount namespace staying with the builder's userns is on
> > > > purpose
> > > > though, that's what keeps the cell from mounting anything no
> > > > matter what
> > > > capabilities it was given.  The builder sets the tree up and
> > > > hands it
> > > > over, so the cell only ever has what it was given, and the mount
> > > > code
> > > > isn't something it can attack from the inside.
> > > 
> > > I don't get it.
> > > 
> > > Using the builder's user namespace means that the contained
> > > processes
> > > can't be ns_capable on mntns->userns.  But this solves very few
> > > problems unless you also deny the contained processes the ability
> > > to
> > > unshare userns and make a new mountns, and if you can do that,
> > > surely
> > > you can also deny the ability to modify the mount namespace.
> > > 
> > > As just one example, a mount namespace could have a little flag to
> > > say
> > > that it's *in* one userns but its owner is a different userns.
> > > 
> > > > 
> > > > > cells: I find it *incredibly annoying* that one generally
> > > > > cannot put
> > > > > new mounts into an existing container using most existing
> > > > > container
> > > > > managers.  I hit this on a surprisingly regular basis.  You
> > > > > seem to be
> > > > > baking this into the whole cells design.  Why?
> > > > 
> > > > By design.  Allowing changes to a running container is what
> > > > causes the
> > > > problems.  If you need another mount, tear it down and build it
> > > > again.
> > > 
> > > What problems?
> 
> Dear friends,
> 
> Dear Andy,
> 
> > 
> > I'll add:
> > 
> > On a non-container Linux system, you can hot-add a removable drive.
> > On a Linux-hosted VM, you can hot-add all kinds of devices, with or
> > without the help of the hypervisor.  (The hypervisor can hot-add a
> > device, and the guest can mount network devices or newly added USB
> > devices on a port that was already assigned, etc.)
> > 
> > For some reason, on Docker and its sort-of-clones, approximately the
> > best you can do is rbind in a directory and then mount things into
> > that directory from outside.  This is sad.
> 
> +1
> 
> I guess the root reason here is what you've mentioned - for VMs we have
> a clear separation of the host-side (hypervisor can hot-plug a device
> to be visible on a PCI bus, for example) and some agent on the guest
> side can react on this change and do something depending on how VM's
> owner has configured it.
> 
> For containers, we usually don't have an agent (at least in LXC, OpenVZ
> and Docker too). So it is a container manager's work to figure out how
> to hotplug a new filesystem for example and where to place the mount.
> And this was always a reason for some crazy security issues, when some
> privileged process on the host was entering a container's namespaces
> (partially) and then suddenly become trace-able or bring some host FDs
> (and these FDs could be a way to escape via (struct file*)->f_cred
> permission delegation model).
> 
> Another reason is that in VM you hotplug a device, while in container
> you can only hotplug a mounted filesystem. And for devices we don't
> care under which major/minor they land and so on - again, because we
> have systemd for example and it can figure this out. For filesystem we
> need to know where to place in in a mount namespace tree from the
> beginning (we still don't allow mounting a block-device based
> filesystems inside user namespaces).
> 
> I really like your point and that would be great if we can solve this
> somehow in a new design.

This is for v4 (latest).

MOVE_MOUNT_T_MNTNS takes any nsfs CLONE_NEWNS fd, and populates
CLONE_EMPTY_MNTNS directly and attaches live submounts without setns()
and FSCONFIG_SET_ROOTNS mounts FS_USERNS_MOUNT filesystems unprivileged
without entering userns.

The gaps would be open_tree(OPEN_TREE_CLONE) gating (it's now against
host), uid_map/gid_map prepopulation and a flag to deny mount table
changes inside rootns() container while keeping external hot-mounts
enabled.

Those are totally addressable issues.

Br, Jarkko
 

  reply	other threads:[~2026-11-20 13:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 23:13 [RFC PATCH v2 00/13] Namespace for namespace roots Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 01/13] nsproxy: Pass nsproxy to create_new_namespaces() Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 02/13] rootns: Add core infrastructure for root namespaces Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 03/13] rootns: Track init lifecycle via copy_process() and pid_namespace Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 04/13] rootns: Add rootns_create() system call Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 05/13] rootns: Add rootns_wait() " Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 06/13] rootns: Add rootns_kill() " Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 07/13] fork: Support CLONE_INTO_ROOTNS in clone3() Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 08/13] fs: Support FSCONFIG_SET_ROOTNS in fsconfig() Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 09/13] fs: Support installing rootns mount trees via move_mount() Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 10/13] arch: Wire up rootns system calls Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 11/13] docs: Document root namespace uAPI Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 12/13] selftests/rootns: Add root namespace test suite Jarkko Sakkinen
2026-11-17 23:13 ` [RFC PATCH v2 13/13] MAINTAINERS: Add entry for ROOT NAMESPACE Jarkko Sakkinen
2026-11-18 14:47 ` [RFC PATCH v2 00/13] Namespace for namespace roots Josef Bacik
2026-11-18 15:28   ` Jarkko Sakkinen
2026-11-18 15:39     ` Jarkko Sakkinen
2026-11-18 15:46       ` Jarkko Sakkinen
2026-11-18 16:59 ` Andy Lutomirski
2026-11-18 17:04   ` Jarkko Sakkinen
2026-11-18 17:08     ` Jarkko Sakkinen
2026-11-18 17:30       ` Jarkko Sakkinen
2026-11-18 17:46       ` Andy Lutomirski
2026-11-18 18:23         ` Jarkko Sakkinen
2026-11-19 17:30         ` Josef Bacik
2026-11-19 17:43           ` Jarkko Sakkinen
2026-11-19 17:51             ` Jarkko Sakkinen
2026-11-19 22:50           ` Andy Lutomirski
2026-11-19 23:27             ` Andy Lutomirski
2026-11-20 12:32               ` Alexander Mikhalitsyn
2026-11-20 13:13                 ` Jarkko Sakkinen [this message]
2026-11-20 13:24                   ` Alexander Mikhalitsyn

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=awBHZO2VwWyJzvBN@kernel.org \
    --to=jarkko@kernel.org \
    --cc=alex@amutable.com \
    --cc=brauner@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jack@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kees@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=paul@paul-moore.com \
    --cc=sergeh@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