From: Jarkko Sakkinen <jarkko@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: bpf@vger.kernel.org, containers@lists.linux.dev,
linux-api@vger.kernel.org, linux-arch@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-mm@kvack.org,
linux-security-module@vger.kernel.org,
Aleksa Sarai <aleksa@amutable.com>,
Alexander Mikhalitsyn <alex@amutable.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andy Lutomirski <luto@amacapital.net>,
Arnd Bergmann <arnd@arndb.de>,
Christian Brauner <brauner@kernel.org>,
David Howells <dhowells@redhat.com>,
Eric Biggers <ebiggers@kernel.org>,
Giuseppe Scrivano <giuseppe@scrivano.org>,
Hugh Dickins <hughd@google.com>, Jan Kara <jack@suse.cz>,
Jeff Layton <jlayton@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Josef Bacik <josef@toxicpanda.com>, Kees Cook <kees@kernel.org>,
KP Singh <kpsingh@kernel.org>,
Lennart Poettering <lennart@poettering.net>,
Neal Gompa <neal@gompa.dev>, Oleg Nesterov <oleg@redhat.com>,
Paul Moore <paul@paul-moore.com>,
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
Serge Hallyn <sergeh@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Subject: Re: [RFC PATCH v7 00/26] userland: Userland containers
Date: Wed, 25 Nov 2026 18:24:16 +0200 [thread overview]
Message-ID: <awcLsCALUwJ1Qlcc@kernel.org> (raw)
In-Reply-To: <awYJnFNt9kkBqj59@kernel.org>
On Wed, Nov 25, 2026 at 12:03:12AM +0200, Jarkko Sakkinen wrote:
> On Sun, Nov 22, 2026 at 09:35:13PM +0200, Jarkko Sakkinen wrote:
> > OVERVIEW
> > ========
> >
> > A userland is an anonymous-inode control object with separate build and
> > live phases that binds together:
> >
> > 1. A full set of detached namespaces owned by a fresh user namespace,
> > with optional build-phase opt-in sharing (USERLAND_SHARE_NSFD).
> > 2. A dedicated PID namespace for spawning processes into, signaling
> > members, and polling or waiting on PID 1 exit.
> > 3. An initially empty mount namespace (CLONE_EMPTY_MNTNS) populated
> > directly in its target user namespace before going live, without
> > inheriting host mounts or cloning staged trees, while still allowing
> > new mounts to be attached at runtime.
> >
> > Work on this feature started in 2025 after reviewing David Howells'
> > container object patch set [1], whose underlying mechanics made sense to
> > me as a continuation of earlier container object efforts [2]. The
> > lifecycle follows a staircase initialization model similar to the Intel
> > SGX driver, without an embryonic task state or a parallel namespace
> > syscall API, pairing a compact policy-agnostic implementation with an
> > allow-list security model (with LSM hooks) and runtime mount hotplug.
> >
> > While the patch set is manually written, the original motivation came
> > from isolating LLM agents. Running untrusted agent workloads made it
> > clear that OCI runtimes need to minimize their live configuration
> > surface.
> >
> > Assembling mounts, credentials, and namespaces inside helper processes
> > with a half-configured container is what I see as the main challenge,
> > and the existential debate around namespaces and container objects is an
> > unfocused discussion topic.
> >
> > [1] https://lore.kernel.org/all/155059610368.17079.2220554006494174417.stgit@warthog.procyon.org.uk/
> > [2] https://lwn.net/Articles/1102593/
> >
> > IMPLEMENTATION
> > ==============
> >
> > Standalone fd-based namespace configuration (patches 01-07) decouples
> > user and mount namespace setup from live helper tasks. userns_set_idmap()
> > atomically configures USERNS_SETGROUPS_ALLOWED policy and UID, GID, and
> > project ID mappings on a CLONE_NEWUSER nsfs fd, checking current_cred()
> > so an unprivileged creator can delegate the fd via SCM_RIGHTS to a
> > privileged mapping daemon. move_mount(..., MOVE_MOUNT_T_MNTNS) operates
> > on any non-anonymous mount namespace fd: on an empty mount namespace it
> > installs "/" onto the nullfs root once, attaches relative submounts both
> > before entry and into live mount namespaces, and supports
> > MOVE_MOUNT_CLONE for recursive bind mounts without OPEN_TREE_CLONE.
> >
> > userland_open() allocates a userland instance backed by a pollable
> > anonymous-inode fd, creating a fresh owning user namespace and a full
> > set of detached namespaces: empty mount (CLONE_EMPTY_MNTNS), PID, UTS,
> > IPC, network, cgroup, and time. ioctl(ufd, USERLAND_GET_NSFD, nstype)
> > returns nsfs file descriptors for member namespaces, and
> > ioctl(ufd, USERLAND_SHARE_NSFD, ns_fd) replaces a member cgroup, IPC,
> > UTS, network, or time namespace while the userland is in USERLAND_INIT.
> >
> > Superblocks are configured directly in the target user namespace via
> > fsopen(), FSCONFIG_SET_USERLAND, and fsmount() for filesystems opting
> > into FS_USERLAND_MOUNT (tmpfs, ramfs, devpts, proc, mqueue) or
> > FS_USERNS_DELEGATABLE, allowing unprivileged callers to assemble mounts
> > without holding CAP_SYS_ADMIN in their own user namespace or entering
> > the target user namespace first.
> >
> > Once "/" is installed, processes are spawned into the userland via
> > clone3() with CLONE_INTO_USERLAND and struct clone_args.userland,
> > without modifying the calling process's own live state first. Pairing
> > CLONE_INTO_USERLAND with CLONE_VFORK and opening the target binary via
> > openat2(..., RESOLVE_IN_ROOT) on the retained "/" mount fd allows
> > spawning with execveat() directly into the target root.
> >
> > The first entrant becomes PID 1; once it exits and
> > zap_pid_ns_processes() reaps all members, poll() reports EPOLLHUP and
> > waitid(P_USERLAND, ufd, infop, options, NULL) returns init's exit
> > status without consuming it. pidfd_send_signal(ufd, sig, NULL, 0) walks
> > pid_ns->idr under tasklist_lock to signal member thread groups, and
> > dedicated LSM hooks mediate userland allocation, teardown, namespace
> > sharing, process entry, and signal delivery.
> >
> > SYSCALLS
> > ========
> >
> > Two new system calls are proposed:
> >
> > 1. userland_open(): open an opaque staircase-initialized container
> > object (modeled on Intel SGX enclave initialization with separate
> > build and live states) with no embryonic state, opting selected
> > shared namespaces in via an allow-list instead of unshare semantics.
> > 2. userns_set_idmap(): configure all UID, GID, and project ID map
> > extents for a container user namespace in a single atomic system
> > call.
> >
> > Extensions to existing system calls:
> >
> > 1. move_mount() (MOVE_MOUNT_T_MNTNS, MOVE_MOUNT_CLONE): install "/" and
> > relative submounts into a mount namespace fd before entry or at
> > runtime, and recursively bind-clone mount trees without
> > OPEN_TREE_CLONE.
> > 2. clone3() (CLONE_INTO_USERLAND, struct clone_args.userland): spawn
> > PID 1 and subsequent processes directly into a userland without
> > modifying the calling process's own live state first.
> > 3. fsopen() / fsconfig() / fsmount() (FSCONFIG_SET_USERLAND): bind a
> > filesystem context to a userland's namespaces and create mounts
> > without entering its user namespace.
> > 4. waitid() (P_USERLAND): wait on a userland fd for PID 1 exit and read
> > its exit status without consuming it.
> > 5. pidfd_send_signal(): broadcast signals to member thread groups via a
> > userland fd.
> > 6. ioctl() (USERLAND_GET_NSFD, USERLAND_SHARE_NSFD): open member nsfs
> > file descriptors and opt selected namespaces into existing nsfs fds
> > during USERLAND_INIT.
> >
> > HOTPLUG
> > =======
> >
> > 1. Host calls userland_open().
> > 2. Host sets uid/gid maps with 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_USERLAND) (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() /
> > fsconfig(FSCONFIG_SET_USERLAND) / 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().
>
> The initial ad-hoc testing of hotplug using a bare metal x86-64 machine
> and systemd-nspawn has been successful. The kselftest seems provide
> pretty good guarantees for the basic stability; using the syscalls has
> caused no issues so far.
>
> I took some time to go through my experimental SystemD patch files and
> sliced them so that they ought to be easy to bisect and refactor. They
> should be also quite easy to read, understand and evaluate. Finally, I
> removed the shitty patch files from my test harness repository.
>
> Resulting outcomes of all of this are:
>
> 1. Rebased RFC v7 patches with refined LSM support and fixes to the
> known issues as of today:
> https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/log/?h=userland
> 2. SystemD patches:
> https://github.com/jarkkojs/systemd/commits/userland/
>
> No new issues were found during testing, other than fixing the issues
> reported to this thread. This is all feels fairly nice, clean and
> stable.
Possibly userns_set_idmap() should be cut into a patch set of its own,
as it stands as a feature on its own, and is likely agreeable part for
any possible solution. I'm open to that.
Br, Jarkko
prev parent reply other threads:[~2026-11-25 16:24 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 19:35 [RFC PATCH v7 00/26] userland: Userland containers Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 01/26] userns: Factor out idmap validation and commit helpers Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 02/26] userns: Add userns_set_idmap() system call Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 03/26] arch: Wire up " Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 04/26] mount: Add mnt_ns_get_root() Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 05/26] mount: Enforce mount_too_revealing() for foreign mntns Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 06/26] mount: Support MOVE_MOUNT_T_MNTNS in move_mount() Jarkko Sakkinen
2026-11-22 20:02 ` sashiko-bot
2026-11-22 19:35 ` [RFC PATCH v7 07/26] mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS Jarkko Sakkinen
2026-11-22 20:28 ` bot+bpf-ci
2026-11-23 14:05 ` Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 08/26] userns: Factor out install_user_ns_cred() Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 09/26] nsproxy: Expose create_new_namespaces() Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 10/26] userland: Add core infrastructure Jarkko Sakkinen
2026-11-22 20:28 ` bot+bpf-ci
2026-11-22 19:35 ` [RFC PATCH v7 11/26] userland: Track init lifecycle via copy_process() and pid_namespace Jarkko Sakkinen
2026-11-22 20:09 ` bot+bpf-ci
2026-11-22 19:35 ` [RFC PATCH v7 12/26] userland: Add userland_open() system call Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 13/26] userland: Add USERLAND_GET_NSFD ioctl Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 14/26] userland: Add USERLAND_SHARE_NSFD ioctl Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 15/26] exit: Support P_USERLAND in waitid() Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 16/26] signal: Support userland fds in pidfd_send_signal() Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 17/26] fork: Support CLONE_INTO_USERLAND in clone3() Jarkko Sakkinen
2026-11-22 20:01 ` sashiko-bot
2026-11-22 20:28 ` bot+bpf-ci
2026-11-22 19:35 ` [RFC PATCH v7 18/26] fs: Support FSCONFIG_SET_USERLAND in fsconfig() Jarkko Sakkinen
2026-11-22 19:58 ` sashiko-bot
2026-11-22 20:28 ` bot+bpf-ci
2026-11-22 19:35 ` [RFC PATCH v7 19/26] proc: Implement ->set_userland() fs_context operation Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 20/26] ipc/mqueue: " Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 21/26] security: Add userland LSM hooks Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 22/26] bpf: Register " Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 23/26] arch: Wire up userland_open() system call Jarkko Sakkinen
2026-11-22 19:35 ` [RFC PATCH v7 24/26] docs: Document userland uAPI Jarkko Sakkinen
2026-11-22 20:09 ` bot+bpf-ci
2026-11-22 19:35 ` [RFC PATCH v7 25/26] selftests/userland: Add userland test suite Jarkko Sakkinen
2026-11-22 19:52 ` sashiko-bot
2026-11-22 20:28 ` bot+bpf-ci
2026-11-22 19:35 ` [RFC PATCH v7 26/26] MAINTAINERS: Add entry for USERLAND Jarkko Sakkinen
2026-11-22 20:02 ` [RFC PATCH v7 00/26] userland: Userland containers sashiko-bot
2026-11-23 0:10 ` Jarkko Sakkinen
2026-11-23 0:13 ` Jarkko Sakkinen
2026-11-23 0:22 ` Jarkko Sakkinen
2026-11-23 0:26 ` Jarkko Sakkinen
2026-11-23 1:08 ` Jarkko Sakkinen
2026-11-23 0:21 ` Alexei Starovoitov
2026-11-23 0:59 ` Jarkko Sakkinen
2026-11-23 1:17 ` Jarkko Sakkinen
2026-11-23 13:25 ` Jarkko Sakkinen
2026-11-23 16:20 ` Jarkko Sakkinen
2026-11-24 1:19 ` Jarkko Sakkinen
2026-11-24 1:28 ` Jarkko Sakkinen
2026-11-24 3:37 ` Jarkko Sakkinen
2026-11-24 3:58 ` Jarkko Sakkinen
2026-11-24 8:19 ` Jarkko Sakkinen
2026-11-24 8:58 ` Jarkko Sakkinen
2026-11-24 18:35 ` Jarkko Sakkinen
2026-11-24 22:03 ` Jarkko Sakkinen
2026-11-25 16:24 ` Jarkko Sakkinen [this message]
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=awcLsCALUwJ1Qlcc@kernel.org \
--to=jarkko@kernel.org \
--cc=aleksa@amutable.com \
--cc=alex@amutable.com \
--cc=arnd@arndb.de \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=containers@lists.linux.dev \
--cc=corbet@lwn.net \
--cc=dhowells@redhat.com \
--cc=ebiggers@kernel.org \
--cc=giuseppe@scrivano.org \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kees@kernel.org \
--cc=kpsingh@kernel.org \
--cc=lennart@poettering.net \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=neal@gompa.dev \
--cc=oleg@redhat.com \
--cc=paul@paul-moore.com \
--cc=ptikhomirov@virtuozzo.com \
--cc=sergeh@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zygmunt.krynicki@canonical.com \
/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