lxutil: use permissive drvfs modes by default without metadata#3689
Draft
benhillis wants to merge 1 commit into
Draft
lxutil: use permissive drvfs modes by default without metadata#3689benhillis wants to merge 1 commit into
benhillis wants to merge 1 commit into
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
Newly created drvfs files served over virtiofs come back owned by the volume's default uid/gid (often root) with ACL-derived, fmask-masked modes such as 0o644. A non-root guest user is then denied write access to files it just created, which differs from the legacy 9p drvfs server that exposes the permissive 0o777 default. Permission mapping only makes sense when metadata is enabled, since without it there is no way to record real ownership and the per-class bits are advisory (the host ACL remains the real access gate). Disable permission mapping in LxVolume::new whenever metadata is off so the default mount matches the permissive legacy drvfs behavior, while metadata mounts keep deriving modes from the Windows ACL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5914e0c to
1ea67f3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Windows lxutil filesystem capability detection so that Linux permission “mapping” from Windows ACLs is disabled when the volume is mounted without metadata. This aligns no-metadata mounts with the legacy permissive drvfs behavior, avoiding guest-side VFS denials caused by restrictive mode bits combined with fallback (often root) ownership.
Changes:
- Make
FsContextmutable inLxVolume::newso compatibility flags can be adjusted after mount-option normalization. - Disable
supports_permission_mappingwheneveroptions.metadataisfalse(including when metadata is forced off due to filesystem limitations). - Add detailed inline rationale explaining why ACL-derived modes are counterproductive without metadata-backed ownership.
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.
lxutil: use permissive drvfs modes by default without metadata
Problem
When a drvfs volume is served without the
metadatamount option (the default), newly created files come back to the Linux guest owned by the volume's defaultuid/gid(frequently0/root) with ACL-derived, fmask-masked modes such as0o644. A non-root guest user is then denied write access to files it just created.This is a regression from the legacy 9p drvfs server, which exposes the permissive
0o777default for non-metadata mounts. It surfaces most visibly under containers using auid=0bind mount over virtiofs, where a non-root process cannot write files it owns. See microsoft/WSL#40719.Root cause
FsContextenablessupports_permission_mappingfor any local (non-remote) NTFS volume. With permission mapping on,convert_modederives the Linux mode from the Windows ACLEffectiveAccess(0o666for a normal writable file) and then masks it with the mountfmask(default022), yielding0o644. Because no-metadata mounts cannot record real ownership, the file also falls back to the volume default uid/gid. The combination (root owner +0o644) blocks the non-root creator.Permission mapping only makes sense when
metadatais enabled, because without metadata there is no way to record real ownership and the per-class permission bits are advisory — the host ACL remains the real access gate regardless of the guest mode bits.Change
In
LxVolume::new, disablesupports_permission_mappingwhenevermetadatais off, so the default mount uses the permissive legacy drvfs model (0o777, still clearing write bits for read-only files). Metadata mounts are unchanged and keep deriving modes from the Windows ACL and stored ownership.Validation
cargo check -p lxutil— passes.cargo test -p lxutil— 44 passed, 0 failed. No existing test asserts a specific no-metadata mode, so none regress.supports_permission_mappingconsumer (the stat fallback infs.rs): reachable only on legacy filesystems lackingFILE_STAT_INFORMATION, wheregranted_access = 0is consistent with the permissive fallback path.Filed as a draft for review of the approach before adding a regression test.