fix(windows-vm): strip setgid bit on shared folder to preserve 0700 mount safety - #11891
Open
szaidi-code wants to merge 1 commit into
Open
szaidi-code wants to merge 1 commit into
szaidi-code wants to merge 1 commit into
Conversation
… privacy Fixes omacom#11879 When dockurr/windows runs, its Samba service sets the setgid bit on the shared folder (~/Windows), leaving it with mode 2700 instead of 0700. On Linux/BTRFS, a numeric 'chmod 0700' does not clear an existing setgid bit. Consequently, subsequent launches fail the [[ $shared_mode != 700 ]] safety check in prepare_caller_mounts() and fail to start the VM. 1. In prepare_caller_mounts(), use 'chmod 00700' and explicitly strip setgid and setuid ('chmod ug-s') on pinned storage and shared descriptors. 2. In mounted_leaf_matches(), strip setgid/setuid on the caller-owned mount leaf before checking mode 700 to accommodate containers that mutate permissions. 3. In prepare_user_mount_sources(), also use 'chmod 00700' and 'chmod ug-s'. 4. Add regression test in windows-vm-mount-boundary-test.sh ensuring a setgid shared directory has setgid stripped and preserves 0700 mount privacy.
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.
Problem
When running
dockurr/windowsviaomarchy-windows-vm, Samba or the container's initialization sets the setgid bit on the bound shared folder (~/Windows), resulting in directory permissions2700instead of0700.On Linux / BTRFS, numeric
chmod 0700does not clear an existing setgid bit on a directory. Becauseprepare_caller_mounts()strictly enforces that both storage and shared directories must be mode700([[ $storage_mode != 700 || $shared_mode != 700 ]]), every subsequent launch of the Windows VM fails.Fixes #11879 (part 1)
Solution
prepare_caller_mounts(), usechmod 00700and explicitly runchmod ug-son the pinned file descriptors to strip any setgid/setuid bits left by container services before checking mode700.mounted_leaf_matches(), also clearchmod ug-sbefore comparing the directory mode against700.prepare_user_mount_sources(), usechmod 00700andchmod ug-s.test/shell.d/windows-vm-mount-boundary-test.shverifying that an existing2700(setgid) shared directory has setgid stripped and maintains verified0700privacy across mount checks.Verification
test/shell.d/windows-vm-mount-boundary-test.sh(all 10 checks pass).windows-key-test.sh,windows-vm-compose-test.sh,windows-vm-mount-boundary-test.sh,windows-vm-test.sh) with 100% pass rate.