freenode
Kernel & Low-Level

Kernel RFC proposes a first-class container object

Jarkko Sakkinen's userland design would configure namespaces, mounts, and ID maps on a file descriptor before any process exists.

Jarkko Sakkinen has posted an RFC that would give Linux a first-class container object, so runtimes could assemble isolation in the kernel instead of staging it through helper processes and half-configured tasks.

A userland, in Sakkinen's design, is an anonymous-inode control file. It owns a fresh user namespace and a full set of detached namespaces: mount, PID, UTS, IPC, network, cgroup, and time. The object has a build phase and a live phase, a split he compares to Intel SGX enclave construction. ID maps, optional shared namespaces, and mounts are set on file descriptors before any process exists, with Linux security module hooks in the path. There is no embryonic task and no parallel namespace syscall API.

That is aimed at how containers are built today. Runtimes fork helpers to write uid and gid maps through procfs, stage mounts with unshare, setns, and pivot_root, and keep partially configured state coordinated across live tasks. Signaling every member through procfs is also racy against concurrent forks, and waitid only lets a parent or subreaper collect an exit, so an outside manager holding a container descriptor cannot wait on an init that someone else started, or observe that exit more than once.

The proposed userland_open call creates the control descriptor in its build phase, isolating every namespace by default rather than relying on unshare deny-lists. A build-phase ioctl can replace cgroup, IPC, UTS, network, or time with an existing namespace file, so host-networked sandboxes and sidecars can still opt in, but only before the first process enters and only with CAP_SYS_ADMIN in the relevant user namespaces. A new userns_set_idmap call would set setgroups policy and UID, GID, and project ID extents atomically on a user-namespace file.

Mount setup is meant to avoid inheriting the host or cloning a staged tree. The mount namespace starts empty and is filled in its target user namespace, including at runtime. Filesystem context setup would let a manager with admin rights in that user namespace bind a new context to the userland before any process has entered it, covering tmpfs, ramfs, devpts, proc, and POSIX message queues.

clone3 would gain CLONE_INTO_USERLAND so a multithreaded daemon, which cannot safely call setns on a user namespace or mutate process-wide filesystem state in place, can spawn PID 1 directly into a userland whose root is already installed. Later callers join the running PID namespace until teardown. waitid would grow a userland target that waits until the object is dead and reports init's exit without consuming it. pidfd_send_signal on the same descriptor would deliver one signal to each thread group, including in-flight forks.

The series also adds LSM hooks for creation, teardown, namespace sharing, process entry, and userland-wide signals, and wires Landlock and BPF LSM so those operations are not a side door around existing namespace policy. It builds on earlier container-object work by David Howells, who is credited as co-developer on several pieces. Sakkinen calls the RFC a sequencing-based alternative that closes the design circle; it is not a merged interface.