Fix owner leakage on partial chown in overlay#198
Open
doanbaotrung wants to merge 1 commit into
Open
Conversation
When a guest performs a partial chown to modify only the group (e.g., chown(path, -1, gid)), the overlay allocates a new entry. However, it previously initialized both `e->uid` and `e->gid` to the physical host's `cur_uid` and `cur_gid`. Since `new_owner` was -1, `e->uid` remained the physical host UID (e.g. 501). When guest later stats the file, the overlay unconditionally applied the physical UID, corrupting guest permissions. Solve this by: 1. Initializing new overlay entries with `(uint32_t)-1` for both fields to indicate "no override". 2. Only applying overrides to `st_uid`/`st_gid` in stat if the fields do not equal the `(uint32_t)-1` sentinel. 3. Checking effective UIDs/GIDs against host values before removing redundant entries.
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.
When a guest performs a partial chown to modify only the group
(e.g., chown(path, -1, gid)), the overlay allocates a new entry.
However, it previously initialized both
e->uidande->gidto thephysical host's
cur_uidandcur_gid. Sincenew_ownerwas -1,e->uidremained the physical host UID (e.g. 501). When guest laterstats the file, the overlay unconditionally applied the physical UID,
corrupting guest permissions.
Solve this by:
(uint32_t)-1for bothfields to indicate "no override".
st_uid/st_gidin stat if the fieldsdo not equal the
(uint32_t)-1sentinel.redundant entries.
Fix #137