Re: [RFC PATCH v2 00/13] Namespace for namespace roots
From: Andy Lutomirski
Date: Fri Nov 20 2026 - 14:48:07 EST
> On Nov 20, 2026, at 11:35 AM, Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:
>
> On Fri, Nov 20, 2026 at 03:57:32PM +0200, Jarkko Sakkinen wrote:
>>> On Fri, Nov 20, 2026 at 02:24:57PM +0100, Alexander Mikhalitsyn wrote:
>>> 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. ]
>
> The sequence for hotplug (Andy's use case) breaks down like this and is
> doable:
>
> 1. Host creates rootns(ROOTNS_SEAL_MNTNS).
> 2. Host sets uid/gid maps with NS_USERNS_SET_IDMAP.
> 3. Host populates "/" with MOVE_MOUNT_T_MNTNS, optionally combined with
> MOVE_MOUNT_CLONE for bind mounts.
> 4. Host spawns PID 1 with clone3(CLONE_INTO_ROOTNS) (optionally passing
> an AF_UNIX socketpair fd for communication).
> 5. PID 1 watches /proc/self/ns/mnt via fanotify(FAN_REPORT_MNT |
> FAN_MARK_MNTNS, FAN_MNT_ATTACH) or polls /proc/self/mountinfo.
> 6. On hotplug, host mounts the filesystem via fsopen()/fsmount() (plus
> optional MOUNT_ATTR_IDMAP).
> 7. Host creates the mountpoint with openat2(RESOLVE_IN_ROOT) + mkdirat()
> and attaches the mount with MOVE_MOUNT_T_MNTNS.
> 8. PID 1 receives FAN_MNT_ATTACH and queries the new mount via
> statmount().
>
> ROOTNS_SEAL_MNTS, NS_USERNS_SET_IDMAP and MOVE_MOUNT_CLONE new features
> that are yet to be submitted but they were not tedious to ramp up.
>
> I'll include them to v5 of the patch set. Thanks for underlining this
> part because that led to having those.
>
> Architecture scales to this even if my choices to address these details
> would need some adjustment.
>
> The clear two-phase (build/live) progress with rootns sort of just gives
> room to address stuff like this, and I have hard time to believe that it
> would get much better than this.
FWIW, my EPRIV thing and cap_userns (in the other thread) only address this situation to the extent that people think, if a container has permission to make children that can mount, then the container itself can mount. Unless people think it’s okay to use the *existing* cap_bset to adjust this, which lots of existing container managers due but is very coarse grained.
It would be straightforward IMO to have a single bit on each non-userns namespace type that declares that tasks in that namespace are not ns_capable on that namespace. (Actually making this *useful* may require improved APIs that are kind of the whole point of this discussion.)
I admit I don’t see why sealing a namespace is useful. I like the bit in the previous paragraph better.
>
> Br, Jarkko