Re: [RFC PATCH v3 00/13] Namespace for namespace roots

From
Jarkko Sakkinen <jarkko@kernel.org>
Date
2026-11-19 06:21:31
Also in
linux-doc, linux-fsdevel, linux-kselftest, linux-mm, linux-security-module, lkml
Reply to
Jarkko Sakkinen, 2026-11-19
On Thu, Nov 19, 2026 at 06:43:21AM +0200, Jarkko Sakkinen wrote:
On Wed, Nov 18, 2026 at 10:42:10PM +0200, Jarkko Sakkinen wrote:
quoted
quoted
I.e. before PID 1 and /proc/<pid>/ns/* existss, nsfd for namespace other
than root nsfd can be acquired as follows:

	int mnts_fd = ioctl(root_fd, ROOTNS_GET_NSFD, CLONE_NEWNS);

Unprivileged caller becomes the owner of rootns->user_ns. Each mount
syscall then just checks CAP_SYS_ADMIN against rootns->user_ns.

The user space wiring goes along the lines of:

        int root_fd = rootns_create(ROOTNS_KILL_ON_CLOSE | ROOTNS_CLOSE_ON_EXEC);
        int mntns_fd = ioctl(root_fd, ROOTNS_GET_NSFD, CLONE_NEWNS);

        int tmpfs_fd = fsopen("tmpfs", 0);
        fsconfig(tmpfs_fd, FSCONFIG_SET_ROOTNS, NULL, NULL, root_fd);
        fsconfig(tmpfs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0);
        int rootfs_fd = fsmount(tmpfs_fd, 0, 0);

        move_mount(rootfs_fd, "", mntns_fd, "/", MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_MNTNS);

        struct clone_args args = {
                .flags  = CLONE_INTO_ROOTNS,
                .rootns = root_fd,
        };
        pid_t pid = clone3(&args, sizeof(args));

[BTW, this patch set is pointed out to David and not fsdevel mailing by a
 mishap, apologies.]

I reduced syscalls can be further to only a single syscall: rootns()

The complete API after this:

1. rootns(flags)
2. ioctl(rootfs_fd, ROOTNS_GET_NSFD, ns)
3. ioctl(rootfs_fd, ROOTNS_WAIT, NULL)
4. ioctl(rootfs_fd, ROOTNS_KILL, signum)

An updated version of the patch set is available over here:

https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/log/?h=rootns

In order to find more evidence that the API is trimmed and code has no
extra fat, I tried how LSM hooks size-fit.

Attached are the experimental LSM hooks and while possibly not exactly
right they should not be at least in the ballpar (Paul?).

Not perfect, but very usable, and there's a steady track of convergence
where resolving a bottleneck leads into a better symmetry and coherency
overall.
Orthogonally, solely fd-local security model (as all is tied to fd) is
the best thing ever when defining mandatory access control policies  as
the full flow can be meaningfully described; i.e. roonts(), sendmsg()
and other calls track the fd's data flow with almost the highest
achievable granularity.

Br, Jarkko
Thread (21 messages) 21 messages, 2 authors, last reply 1d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help