Re: [RFC PATCH v2 00/13] Namespace for namespace roots
From: Alexander Mikhalitsyn
Date: Fri Nov 20 2026 - 08:25:07 EST
On Fri, 2026-11-20 at 15:13 +0200, Jarkko Sakkinen wrote:
> 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@xxxxxxxxxxxxxx>
> > > wrote:
> > > >
> > > > On Thu, Nov 19, 2026 at 9:30 AM Josef Bacik
> > > > <josef@xxxxxxxxxxxxxx>
> > > > wrote:
> > > > >
> > > > > On Wed, Nov 18, 2026 at 9:46 AM Andy Lutomirski
> > > > > <luto@xxxxxxxxxxxxxx> 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.
Dear Jarkko,
>
> 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.
Yeah, detached mounts API solves a security issue here, but it does not
fully enable the use-case Andy describes (if I understood it
correctly). My interpretation here is that to fully cover it we need
some well-isolated communication channel between container and
container manager (vsock for containers? :-D). And some well-defined
agreement of how PID 1 inside the container can get an information
about a hotplugg-ed stuff. [ But it could be that I completely
misunderstood and Andy meant something much more simple here. ]
Kind regards,
Alex
>
> Br, Jarkko
>