Fix Windows VM helper rejecting setgid source directories - #9783
Conversation
|
Reviewed by Claude Opus 5, with an independent second opinion from Codex at xhigh. Both reached the same verdict, and Codex contributed two mechanisms the first pass had not worked out; its independence is not currently guaranteed, so the agreement is worth less than those two findings. What was checked. The diff against The mode fix is correct, and it is the right kind of repair. On coreutils 9.11, The sentinel is where the defects are. Its premise holds — dockur's
Neither of the two behaviours that distinguish this PR — the sentinel under the privileged path, and Nothing was pushed to your branch. Finding 1 needs a design decision rather than a patch — drop the privileged creation, or open with Waiting on the maintainer, both for that choice and for a decision on the sentinel. |
|
Addressing the review by dropping privileged sentinel creation.
This revision:
The world-writable window is now only during guest boot, not until the next privileged action. |
GNU chmod leaves setuid/setgid on directories for numeric modes of four digits or fewer, so chmod 0700 cannot satisfy the exact-700 mount check when ~/Windows was created with g+s. Harden with a-s,u=rwx,go= and print the observed modes when the check still fails.
samba.sh treats an empty /shared bind as uninitialized and chmod 2777s it at container start, undoing the host 700 privacy check after every launch. Keep a hidden sentinel in the share and re-harden the directory after docker compose up.
Creating ~/.omarchy-keep as root in a caller-owned directory is a symlink-follow write primitive. Restore mode 700 on the pinned directory inodes after the guest reports ready, and never fail a successful start on that chmod.
c194fcf to
e3d3190
Compare
restore_shared_privacy also chmodded $LEGACY_SHARED, which is $HOME/Windows: a pathname the unprivileged caller owns. The [[ -d && ! -L ]] test and the chmod are two syscalls, so the caller can swap the directory for a symlink in between and make the root half of __priv_up_wait chmod an arbitrary path to 0700 with the set-ID bits cleared. On a worker a swapper loop won that race on its 260th iteration, taking a root-owned 4755 binary outside the caller's home to root:700. The loop's other element already covers the case. $EXPECTED_SHARED sits in the root-owned 0711 boundary tree the caller cannot write, and assert_mounts_safe has just proved through mounts_ready that it is a bind of the same inode as $LEGACY_SHARED — so chmodding the anchor is what ~/Windows ends up at, measured rather than assumed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Re-reviewed at Where the previous findings stand. Finding 1 (root create/truncate through New, and pushed as The other loop element already covers the case, so the fix is to delete the legacy one. Still open, for you rather than a patch from me: What was checked. The delta only — everything under Codex reached the arbitrary-chmod finding independently and rated it High; its independence is not currently guaranteed, so treat that as agreement rather than confirmation. What it contributed on its own terms is the dockur Related. This closes #9374 and #9698, which the body names, and also #9334, #9540, #9567, #9884 and #9943, which are the same setgid symptom — worth adding to the body so they close together. #9746 and #9943 are the container-re-adds-the-bit variant, and this is the only one of the five open PRs on this root cause that addresses it: #9322, #9414 and #9504 change the two Waiting on you for the |
install uses priv up, which returned as soon as the container started and never re-hardened ~/Windows after samba.sh chmod 2777. Wait for that 2777 (or the shared-folder log line) before restoring, and also restore after dc down and when the guest-ready wait times out.
|
Picked both of the remaining options.
This revision:
Still never chmod |
Fixes #9698
Fixes #9374
GNU
chmod 0700leaves setuid/setgid on directories when the numeric mode is four digits or fewer.prepare_caller_mountsthen requires mode700exactly, so a leftoverg+son~/Windows(often2700or2777) makes every privileged VM action fail closed with no diagnostic.This hardens those directories with
chmod a-s,u=rwx,go=(which does clear the special bits) and prints the observed modes if the check still fails.dockur
samba.shalsochmod 2777s an empty/sharedbind at container start, so a successful launch immediately undoes the host privacy mode. A hidden.omarchy-keepsentinel keeps the share non-empty, and the helper re-hardens~/Windowsafterdocker compose up.Covered by a user-side
prepare_user_mount_sourcestest and a root-namespace case that starts from2700/2777sources.