Skip to content

Stop user namespace probes from leaving an unshare process behind - #14790

Open
namespaceMarcello wants to merge 4 commits into
omacom:quattrofrom
namespaceMarcello:test/unshare-probe-hang
Open

namespaceMarcello wants to merge 4 commits into
omacom:quattrofrom
namespaceMarcello:test/unshare-probe-hang

Conversation

@namespaceMarcello

@namespaceMarcello namespaceMarcello commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Where user namespaces are refused, the two probes that map ids (windows-vm-mount-boundary-test.sh and the cross-UID probe in update-stay-awake-security-test.sh) skip as intended but leave an unshare process blocked for good with the test's stdout open. Since #15302 ./test/shell writes each file's output to its own log, so the suite still finishes, but a run as an unprivileged user with subordinate ids (an /etc/subuid entry) leaves one such process per probe behind, and a pipe reading a probe file's output never reaches EOF. Measured on quattro at ac6cb9c in an Arch container on Docker Desktop under Docker's default seccomp profile, as uid 1000 with an /etc/subuid entry, where unshare --user --mount true exits 1: read through | cat, both pipelines were still waiting when a 60 s timeout stopped them; with output to a file, both files finished and each left one unshare process alive. With this change both finish either way and leave none.

The cause is in util-linux unshare (read in 2.42.4, the same on master). With --map-users, --map-groups or --map-auto it forks a helper to write the mappings before calling unshare(2), and the helper waits on an eventfd for the parent to report that the call succeeded. When the call fails, the parent exits through err() without telling it, so the helper stays blocked, reparented to init, with the test's stdout still open. The test file exits, but a pipe reading its stdout never reaches EOF. --map-root-user and --map-current-user on their own write the mappings without a helper and fail cleanly, which is why the other namespace tests in the suite are unaffected.

This adds user_namespace_available to base-test.sh. It runs unshare --user --mount true: the same unshare(2) flags the probes use, without mappings, so nothing is forked. The probes ask it before trying a mapping form. Where user namespaces work it succeeds and the probes run exactly as before. Only test/ and docs/ change.

The new user-namespace-probe-test.sh puts a stub unshare first in PATH that fails every call and, for the mapping forms, leaves a process holding stdout the way util-linux does. It reads the Windows VM boundary probe through a pipe under timeout, which kills the whole process group if the pipe stays open, so a regression fails the file instead of hanging it. docs/testing.md gets a bullet next to the existing note on inherited output pipes.

This touches the same probe line in windows-vm-mount-boundary-test.sh as #11768, which changes the root path there. Whichever lands second needs a one-line rebase, and the unprivileged --map-auto branch that #11768 keeps still needs the guard.

Validation: in the same container, user-namespace-probe-test.sh fails on quattro (its 10 s timeout fires) and passes with this change. Breaking each assertion of the file on its own (the probe exiting non-zero, or reporting a pass instead of a skip) makes the file fail at that assertion. With seccomp unconfined and the newuidmap/newgidmap capabilities restored, so that user namespaces work, the three touched files print identical results before and after: 11, 5 and 15 passing checks, no skips. On 2026-10-10, before #15302, ./test/all ran to the end in the container with this change, in about 8 minutes and with no manual intervention: 4716 checks ok, 43 of them skipped. The 9 files that fail there fail the same way on quattro in the same container, so none of them comes from this change (no systemd as PID 1, no gum, /etc/machine-id or limine in the image, plus reds already tracked upstream).

Merged quattro at 4907fcd into the branch, without a rebase so the review history stays. #17000 deleted remove-dev-env-sudo-security-test.sh, so two of the three probes remain, both still guarded here; that file was the only conflict. No test added since maps ids with --map-users, --map-groups or --map-auto without the guard. The hang is still there: in the same container, on another branch merged with the same quattro, update-stay-awake-security-test.sh run on its own through a pipe (| tee) stopped after its cross-UID skip and held the pipe for over ten minutes until the container was killed, and the full suite on that branch left two unshare helpers behind; on this branch the file finishes and the full suite leaves none. After the merge the three touched files pass. ./test/all at 550dc5f: 7111 checks ok, 74 of them skipped, and the one failure (elsewhen, no systemd as PID 1) fails on quattro too.

Updated on 2026-11-13 after greptile's review, in 6372e80 and 1ba3362: the name scan is gone (it checked the text, not the behaviour); docs/testing.md describes the per-file logs and the pipes that still hang; the comments and assertion messages speak of a reader waiting on a pipe instead of the runner's tee; and the first paragraph is measured again on quattro at ac6cb9c.

Written by Claude Code (AI assistant) on behalf of @namespaceMarcello, who directs this work.

Where user namespaces are refused, as under Docker's default seccomp
profile, three shell tests skip as intended and then leave ./test/shell
waiting forever. Their probes pass --map-users, --map-groups or
--map-auto, and util-linux unshare forks a helper to write those
mappings before it calls unshare(2). When the call fails the parent
exits without waking the helper, which stays blocked on an eventfd with
the test's stdout open, so the runner's tee never sees EOF.

Add user_namespace_available to base-test.sh. It tries the same
namespaces without mappings, a form that forks nothing and fails
cleanly, and the three probes ask it before trying a mapping form. A
new test runs the Windows VM boundary probe against an unshare stub
that behaves like util-linux in that sandbox, and checks that every
test mapping ids calls the helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds user_namespace_available and checks it before the two remaining probes try mapping ids.

  • Namespace probes skip cleanly when user namespaces are refused.

Reviews (4) · Last reviewed commit: "Name the pipe a leftover unshare helper ..." · Reviewed by Greptile

@jandrusk

Copy link
Copy Markdown

Good catch on the util-linux unshare --map-users helper hanging when the unshare(2) fails — that would leave tee waiting forever. Probing with unshare --user --mount true (no mapping helper) before the mapped forms looks right, and documenting it in docs/testing.md helps. Ready for review.

@omarchybot

Copy link
Copy Markdown
Collaborator

This has not been reviewed yet, because its classification is unsettled: every item here is classified by two models separately, and the second opinion (Codex Medium) was not available for this one, as today's cap on reviewer calls was already spent. The reviewer itself is up, so this is a matter of budget, not of the pull request.

Read so far, by Claude Opus 5.5 alone: the diff at cd29040 against quattro, which still merges cleanly. Nothing was run, and nothing here is a finding yet. It touches the same probe line in windows-vm-mount-boundary-test.sh as #11768 and #15115, so whichever of the three lands later will need that line reconciled; #15115 builds the --map-auto arguments in an array, which the new user-namespace-probe-test.sh check would require to call user_namespace_available as well.

Next: once the classification is settled, the change is run on a worker (the probe test failing on quattro and passing here, then the touched files under the suite) and reviewed by both models, and the result is posted here. Nothing is needed from you in the meantime.

omacom#17000 deleted remove-dev-env-sudo-security-test.sh, whose namespace
probe this branch gated; the other two probes and the shared helper
merge cleanly. No test added since maps ids with unshare without
calling user_namespace_available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread docs/testing.md Resolved
namespaceMarcello and others added 2 commits November 13, 2026 12:09
The scan checked that each mapping test mentions user_namespace_available, not that the probe runs before the mapping. The test header, the base-test.sh comment and the testing.md bullet still described ./test/shell as piping each file through tee; it writes each file's output to its own log since omacom#15302, so they now say what a reader waiting on a pipe does.
The assertion messages still spoke of the runner's pipe, and the testing.md bullet left out a $(...) around a mapping unshare inside a test, which holds the test file and the runner with it. The comments are rewrapped to 80 columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@namespaceMarcello namespaceMarcello changed the title Stop user namespace probes from hanging the shell suite Stop user namespace probes from leaving an unshare process behind Nov 13, 2026
@greptile-apps

greptile-apps Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reproduced the leak with real util-linux 2.42.4 on a disposable Omarchy ISO worker, as uid 1000 with subordinate IDs and seccomp denying unshare(2). On current quattro at 419a5a7, both probes exit successfully but leave an unshare process holding stdout open. At 1ba3362, both close stdout and leave no helper. Removing only the two guards brings both leaks back. The new regression test also fails at its intended timeout assertion with the Windows guard removed.

The namespace-enabled paths pass on the worker: 11 Windows boundary checks, 15 stay-awake security checks including cross-UID, and the new regression check. ./test/all produced 7,406 passing assertions and six failed files outside this change. ASCII, branding animation and first-run pass after correcting the worker's locale and copied Git metadata. Runtime smoke also fails on current quattro; agent-account execution and background-intro lifecycle also fail on the original quattro base 4907fcd. No failure remains attributable to this PR. GitHub CI is green.

GPT-6 High in Codex reviewed this head, with second opinions from Opus 5.5 High and muse-wonder via pi, thinking high. Neither found a blocking defect; their agreement does not guarantee independence. No code changes were needed.

Nothing is needed from the author; this waits on the maintainer. #11768 and #15115 address a separate root mount-isolation bug in the same Windows test. Whichever change lands later will need to preserve this guard when reconciling that block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants