Repository navigation
fix(subos): pasta joins the sandbox user namespace when the supervisor is root - #733
Merged
Merged
Conversation
passt drops root to nobody when it starts as root in the init user namespace, before it joins an existing user namespace. A carrier's machine runs everything as root, so the target userns is owned by root and nobody cannot open /proc/<pid>/ns/user -- net=nat then fails with exit 125 even though the sandbox itself never starts. Pass --runas <uid>:<gid> at both pasta spawn sites when euid is 0, so pasta keeps the namespace owner's identity for the join. Non-root hosts are unchanged. Fixes openxlings#732 Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
net=natis unusable on Windows: entering a SubOS in the WSL 2 carrier prints the welcome banner and exits immediately with code 125.passt drops root to nobody when it starts as root in the initial user namespace, and
isolate_user()performs that drop before joining an existing user namespace. The carrier runs the session supervisor as root, so the target user namespace is owned by root; nobody cannot open/proc/<pid>/ns/user, and pasta exits 1.This passes
--runas <uid>:<gid>(the namespace owner's identity) at both pasta spawn sites wheneuid == 0. Non-root hosts are unchanged.Fixes #732
Root cause
pasta --pid <pid>resolves the target namespaces to/proc/<pid>/ns/netand/proc/<pid>/ns/user.conf_ugid()defaults tonobodywhen it starts as root in the init user namespace (the carrier's root is in the init namespace).isolate_user()doessetgroups()/setgid()/setuid()beforeenter_userns()when joining a pre-existing user namespace.uid_map 0 0 1), so its owner is root. After the drop to nobody, opening/proc/<pid>/ns/userfails the ptrace access check:Permission denied.xlings::confine::provider::pasta_args()never passed--runas, so this always happens when the supervisor is root — which it always is inside the WSL 2 carrier.On a normal Linux host xlings runs as a non-root user,
conf_ugid()keeps the current uid, and the namespace is owned by that same uid. The same design works there.Changes
modules/subos/src/session/session.cpp— session host path (luban enter,xlings subos use): pass--runas <uid>:<gid>wheneuid == 0.modules/platform/src/process/worker.cpp— worker path (subos exec): the same.The condition keeps non-root behaviour byte-identical; only a root supervisor adds the flag.
Tests
mcpp build --target x86_64-linux-muslin Ubuntu 24.04 (WSL) passes (full build, 10m09s), including both changed translation units:modules/subos/src/session/session.cppandmodules/platform/src/process/worker.cpp— the code that runs inside the WSL 2 carrier.xlings, andluban enter agenton anet=natagent workspace enters the shell and exits 0. Inside the sandbox,/proc/net/devshowsloand the pasta tap (eth3); the previousCouldn't open user namespace ...: Permission denied/ exit 125 is gone.x86_64-pc-windows-msvcbuild passes as well:mcpp build(MSVC 14.52.37025 + Windows SDK 10.0.26100.0) linkstarget/x86_64-windows-msvc/<hash>/bin/xlings.exein 1m45s, and the binary reportsxlings 2026.11.22.1. Note for this machine: the Windows SDK is installed atD:\Windows Kits\10, so mcpp 2026.10.5.3 needsWindowsSdkDir/WindowsSDKVersionset (an environment quirk, not a code issue).net=natSubOS, so this path is exercised in CI.🤖 Generated with Claude Code