Re: [RFC PATCH v2 00/13] Namespace for namespace roots
From: Jarkko Sakkinen
Date: Fri Nov 20 2026 - 14:35:11 EST
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.
Br, Jarkko