From: Jarkko Sakkinen <jarkko@kernel.org>
To: Alexander Mikhalitsyn <alex@amutable.com>,
Andy Lutomirski <luto@amacapital.net>
Cc: 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 21:48:16 +0200 [thread overview]
Message-ID: <awCkANwNDox_99SR@kernel.org> (raw)
In-Reply-To: <awCg5VYXKJvex9vy@kernel.org>
On Fri, Nov 20, 2026 at 09:35:06PM +0200, Jarkko Sakkinen 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.
A completely new feature is NS_USERNS_SET_IDMAP:
nsfs: Support NS_USERNS_SET_IDMAP ioctl
Configuring UID, GID, and project ID mappings or disabling setgroups(2)
for a user namespace currently requires writing to /proc/<pid>/uid_map,
gid_map, projid_map, and setgroups, forcing container managers to spawn a
live process before populating a filesystem owned by that user namespace.
Add the extensible NS_USERNS_SET_IDMAP ioctl on CLONE_NEWUSER nsfs file
descriptors to atomically configure setgroups policy and UID, GID, and
project ID mappings before any process enters the namespace. Enforce the
same single-write and capability invariants against both current_cred()
and filp->f_cred under userns_state_mutex.
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This can be obviously used race-free, and this is thanks to two-phase
initialization pattern I have in place.
Br, Jarkko
next prev parent reply other threads:[~2026-11-20 19:48 UTC|newest]
Thread overview: 49+ 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-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 02/13] rootns: Add core infrastructure for root namespaces Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 03/13] rootns: Track init lifecycle via copy_process() and pid_namespace Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 04/13] rootns: Add rootns_create() system call Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 05/13] rootns: Add rootns_wait() " Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 06/13] rootns: Add rootns_kill() " Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 07/13] fork: Support CLONE_INTO_ROOTNS in clone3() Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 08/13] fs: Support FSCONFIG_SET_ROOTNS in fsconfig() Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 09/13] fs: Support installing rootns mount trees via move_mount() Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 10/13] arch: Wire up rootns system calls Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 11/13] docs: Document root namespace uAPI Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
2026-11-17 23:13 ` [RFC PATCH v2 12/13] selftests/rootns: Add root namespace test suite Jarkko Sakkinen
2026-11-18 23:15 ` sashiko-bot
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
2026-11-20 13:24 ` Alexander Mikhalitsyn
2026-11-20 13:57 ` Jarkko Sakkinen
2026-11-20 19:35 ` Jarkko Sakkinen
2026-11-20 19:47 ` Andy Lutomirski
2026-11-20 19:48 ` Jarkko Sakkinen [this message]
2026-11-20 19:53 ` Andy Lutomirski
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=awCkANwNDox_99SR@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.