Repository navigation
Conversation
…t run `chmod` leaves a directory's setuid/setgid bits alone unless a numeric mode clears them with five or more octal digits. `prepare_caller_mounts` hardened the two bind sources with a four-digit `0700` and then asserted the result was exactly `700`, so any source carrying the setgid bit stayed `2700` and failed the assert on every subsequent launch. This is not an edge case. The container sets the bit itself: dockurr/ windows runs `chmod 2777` on the `/shared` bind source so Samba can write to it, and that source is the host's `~/Windows`. One successful VM run therefore leaves the directory setgid and every later `launch` fails -- before Docker is invoked, with no diagnostic on any stream. Use `00700` at the three directory-hardening sites, and name the directory and its mode on the mismatch branch so the one bring-up failure a user can act on is no longer invisible. Fixes omacom#11940 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Reproduce the exact mode the container leaves on the pinned sources -- 2777 on shared, plus setuid on storage for the symmetric case -- and assert prepare_caller_mounts recovers both the sources and their production anchors to 700, that the final pre-Docker guard accepts the result, and that another local account still cannot read through the hardened anchor. Fails on the pre-fix helper with "root failed to recover from special bits left on the pinned sources"; passes with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
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.
Fixes #9630
Fixes #11490
Fixes #11575
Fixes #11741
Fixes #11940
Fixes #12134
Fixes #12153
Refs #11879 (the setgid half only — the
KVM: entry failed, hardware error 0x0half of that report is unrelated and not addressed here)The earliest and fullest diagnosis is #9630 (2026-09-01), which already identified both the coreutils behavior and the container as the source of the bit. This PR is essentially its suggested fix. Eight reports of this now, two filed today.
There are two other open PRs for this bug: #11714 (2026-09-13) and #12019. Please close whichever of the three is least useful — I'd rather this land once than land twice. What this one adds over the others is noted below.
The bug
prepare_caller_mountshardens the two bind sources and then asserts the result is exactly700:chmodleaves a directory's setuid/setgid bits alone unless a numeric mode clears them with five or more octal digits, so on a setgid source thechmodis a no-op, the assert sees2700 != 700, and the action returns 1 before Docker is ever invoked.The bit is not incidental — the container sets it on every run.
dockurr/windows's/run/samba.shrunschmod 2777on the/sharedbind source so Samba can write to it, and that source is the host's~/Windows. So one successful VM run is enough, and every launch after it fails. Becauseassert_mounts_safegates every privileged action, this takesremoveandinstalldown withlaunch(as #11741 reports).The change
Use
00700at the three directory-hardening sites:prepare_caller_mounts(:583) — the one that causes the failure.prepare_user_mount_sources(:1018) — same normalization at install time, so the sources don't start out dirty.write_credentials(:1061) —~/.config/windowsholds the plaintext RDP password; a stray setgid bit there should not survive the hardening step either.The third site is the one neither #11714 nor #12019 covers.
One call, not two. #9630, #11714 and #12019 all pair a numeric
chmodwith a symbolicu-s,g-s. A single five-digit00700is onechmod(2)per path rather than two, so there is no window in which the source is mode-normalized but still setgid — which matters here, because this runs as root immediately before the directory is bind-mounted into a container.The audit #9630 asks for. Going through the other "numeric chmod then compare" sites:
mounted_leaf_matches(:518) applies the same strict$mode == 700test to the bind target. It shares an inode with the source, so this fix covers it — and that's also why loosening the comparison at:590instead would be wrong: the rejection would just move tomounts_ready.prepare_boundary_component(:267) useschmod "$mode"but verifies throughassert_boundary_dir, which only masks022. Setgid there is tolerated, so it is not a failure path. I left it alone rather than widen the diff; happy to make it consistent if you'd prefer.Regression test
Extends
test/shell.d/windows-vm-mount-boundary-test.shwith the drift the container actually leaves —2777on the shared source, plus setuid on storage for the symmetric case — and assertsprepare_caller_mountsrecovers both the sources and their production anchors to700, thatmounts_readythen accepts the result, and that uid 1001 still cannot read through the hardened anchor.Credit where it's due: #11714 had the idea of covering this in the boundary suite first, and if you merge that one instead, its test is the part worth keeping.
Testing
test/shell.d/windows-vm-mount-boundary-test.sh,windows-vm-test.shandwindows-vm-compose-test.shall pass; the boundary suite fails at the new assertion whenbin/omarchy-windows-vmis reverted to the pre-fix version.Also verified against a real VM on Omarchy 4.0.3-1: reproduced the failure (
bash -xconfirmsshared_mode=2700→return 1), applied the patch, and confirmed bring-up from a2777~/Windowsacross repeated stop/start cycles, including runs where Samba re-applied2777in between.Environment: Omarchy 4.0.3-1, coreutils 9.11, Docker 29.7.2 / Compose 5.5.1, btrfs
/home, user not in thedockergroup (so thepkexecpath).On the error message
The
>&2message #9630 and #11940 ask for is included, naming both directories and their actual modes. It only helps terminal callers — #12153 makes the point I can't fix in this hunk:windows-vm.desktopis written withTerminal=false, so from the app grid this still surfaces as nothing but the generic critical notification. Genuinely addressing #9630's second ask means routing the reason intoomarchy-notification-sendinlaunch_windows, which is a bigger change than this bug fix warrants. Happy to follow up separately, or drop the message hunk if you'd rather keep this minimal.🤖 Generated with Claude Code