Skip to content

fix(subos): pasta joins the sandbox user namespace when the supervisor is root - #733

Merged
Sunrisepeak merged 1 commit into
openxlings:mainfrom
mybna134:fix/net-nat-pasta-runas
Nov 22, 2026
Merged

Sunrisepeak merged 1 commit into
openxlings:mainfrom
mybna134:fix/net-nat-pasta-runas

Conversation

@mybna134

@mybna134 mybna134 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

net=nat is 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 when euid == 0. Non-root hosts are unchanged.

Fixes #732

Root cause

  1. pasta --pid <pid> resolves the target namespaces to /proc/<pid>/ns/net and /proc/<pid>/ns/user.
  2. passt's conf_ugid() defaults to nobody when it starts as root in the init user namespace (the carrier's root is in the init namespace).
  3. isolate_user() does setgroups() / setgid() / setuid() before enter_userns() when joining a pre-existing user namespace.
  4. The user namespace was created by the root supervisor (uid_map 0 0 1), so its owner is root. After the drop to nobody, opening /proc/<pid>/ns/user fails the ptrace access check: Permission denied.
  5. 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> when euid == 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

  • Manual reproduction inside the carrier:
# default: passt drops to nobody before the join
pasta --config-net --quiet -t none -u none -f --pid /tmp/p1.pid <child>
# -> rc=1, "Couldn't open user namespace /proc/<child>/ns/user: Permission denied"

# namespace owner's identity
pasta --config-net --quiet -t none -u none -f --runas 0:0 --pid /tmp/p2.pid <child>
# -> rc=0
  • mcpp build --target x86_64-linux-musl in Ubuntu 24.04 (WSL) passes (full build, 10m09s), including both changed translation units: modules/subos/src/session/session.cpp and modules/platform/src/process/worker.cpp — the code that runs inside the WSL 2 carrier.
  • End-to-end in the carrier: the built Linux binary was used as the carrier's xlings, and luban enter agent on a net=nat agent workspace enters the shell and exits 0. Inside the sandbox, /proc/net/dev shows lo and the pasta tap (eth3); the previous Couldn't open user namespace ...: Permission denied / exit 125 is gone.
  • Windows x86_64-pc-windows-msvc build passes as well: mcpp build (MSVC 14.52.37025 + Windows SDK 10.0.26100.0) links target/x86_64-windows-msvc/<hash>/bin/xlings.exe in 1m45s, and the binary reports xlings 2026.11.22.1. Note for this machine: the Windows SDK is installed at D:\Windows Kits\10, so mcpp 2026.10.5.3 needs WindowsSdkDir / WindowsSDKVersion set (an environment quirk, not a code issue).
  • Suggested follow-up (not in this PR): a Windows carrier e2e that enters a net=nat SubOS, so this path is exercised in CI.

🤖 Generated with Claude Code

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>
@Sunrisepeak
Sunrisepeak merged commit 4db360a into openxlings:main Nov 22, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Windows: net=nat cannot enter a SubOS - pasta drops root to nobody before joining the sandbox user namespace

2 participants