Repository navigation
Stop user namespace probes from leaving an unshare process behind - #14790
namespaceMarcello wants to merge 4 commits into
Conversation
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>
[Low impact] The PR appears safe to merge; no new actionable issues were found. SummaryAdds
Reviews (4) · Last reviewed commit: "Name the pipe a leftover unshare helper ..." · Reviewed by Greptile |
|
Good catch on the util-linux |
|
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 Next: once the classification is settled, the change is run on a worker (the probe test failing on |
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>
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>
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
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 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. 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. |
Where user namespaces are refused, the two probes that map ids (
windows-vm-mount-boundary-test.shand the cross-UID probe inupdate-stay-awake-security-test.sh) skip as intended but leave anunshareprocess blocked for good with the test's stdout open. Since #15302./test/shellwrites 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/subuidentry) leaves one such process per probe behind, and a pipe reading a probe file's output never reaches EOF. Measured onquattroat ac6cb9c in an Arch container on Docker Desktop under Docker's default seccomp profile, as uid 1000 with an/etc/subuidentry, whereunshare --user --mount trueexits 1: read through| cat, both pipelines were still waiting when a 60 stimeoutstopped them; with output to a file, both files finished and each left oneunshareprocess 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-groupsor--map-autoit 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 througherr()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-userand--map-current-useron 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_availabletobase-test.sh. It runsunshare --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. Onlytest/anddocs/change.The new
user-namespace-probe-test.shputs a stubunsharefirst inPATHthat 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 undertimeout, which kills the whole process group if the pipe stays open, so a regression fails the file instead of hanging it.docs/testing.mdgets a bullet next to the existing note on inherited output pipes.This touches the same probe line in
windows-vm-mount-boundary-test.shas #11768, which changes the root path there. Whichever lands second needs a one-line rebase, and the unprivileged--map-autobranch that #11768 keeps still needs the guard.Validation: in the same container,
user-namespace-probe-test.shfails onquattro(its 10 stimeoutfires) 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 thenewuidmap/newgidmapcapabilities 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/allran 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 onquattroin the same container, so none of them comes from this change (no systemd as PID 1, nogum,/etc/machine-idor limine in the image, plus reds already tracked upstream).Merged
quattroat 4907fcd into the branch, without a rebase so the review history stays. #17000 deletedremove-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-groupsor--map-autowithout the guard. The hang is still there: in the same container, on another branch merged with the samequattro,update-stay-awake-security-test.shrun 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 twounsharehelpers behind; on this branch the file finishes and the full suite leaves none. After the merge the three touched files pass../test/allat 550dc5f: 7111 checks ok, 74 of them skipped, and the one failure (elsewhen, no systemd as PID 1) fails onquattrotoo.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.mddescribes 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'stee; and the first paragraph is measured again onquattroat ac6cb9c.Written by Claude Code (AI assistant) on behalf of @namespaceMarcello, who directs this work.