chown-overlay fix ID-space mismatch in set and apply guards#200
Merged
jserv merged 1 commit intoJul 14, 2026
Merged
Conversation
765032f to
94d8558
Compare
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
94d8558 to
04a4d54
Compare
Max042004
approved these changes
Jul 14, 2026
jserv
requested changes
Jul 14, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Rebase latest main and resolve conflicts.
chown_overlay_set receives cur_uid/cur_gid from chown_result where
they were taken directly from host_st->st_uid/st_gid (the raw macOS
stat values). new_owner/new_group are guest-virtual UIDs/GIDs.
These two live in different ID namespaces, so comparing them:
next_uid = new_owner == -1 ? cur_uid : new_owner;
if (next_uid == cur_uid && next_gid == cur_gid) goto out;
produces wrong answers whenever host UID != GUEST_UID (e.g. host
user has UID 501, guest runs as GUEST_UID 1000), or whenever the
file already has an overlay entry that virtualises its owner to a
different value.
Two complementary fixes:
fs.c - chown_result:
Apply the existing overlay to a temporary stat copy before
extracting cur_uid/cur_gid. This makes the values passed to
chown_overlay_set reflect what the guest currently sees for the
file rather than the physical host owner.
chown-overlay.c - chown_overlay_set / chown_overlay_apply:
Initialise new overlay entries with the sentinel (uint32_t)-1
("no override for this field") instead of cur_uid/cur_gid.
Resolve sentinels to cur before the stale-entry removal check
so both sides of the comparison use guest-virtual IDs.
Skip sentinel fields in chown_overlay_apply so a partial chown
does not corrupt the untouched field with a stale value.
fix sysprog21#136
04a4d54 to
a124c8d
Compare
Collaborator
Author
|
Rebased and fix conflicted |
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.
chown-overlay: fix ID-space mismatch in set/apply guards
chown_overlay_set receives cur_uid/cur_gid from chown_result where
they were taken directly from host_st->st_uid/st_gid (the raw macOS
stat values). new_owner/new_group are guest-virtual UIDs/GIDs.
These two live in different ID namespaces, so comparing them:
next_uid = new_owner == -1 ? cur_uid : new_owner;
if (next_uid == cur_uid && next_gid == cur_gid) goto out;
produces wrong answers whenever host UID != GUEST_UID (e.g. host
user has UID 501, guest runs as GUEST_UID 1000), or whenever the
file already has an overlay entry that virtualises its owner to a
different value.
Two complementary fixes:
fs.c - chown_result:
Apply the existing overlay to a temporary stat copy before
extracting cur_uid/cur_gid. This makes the values passed to
chown_overlay_set reflect what the guest currently sees for the
file rather than the physical host owner.
chown-overlay.c - chown_overlay_set / chown_overlay_apply:
Initialise new overlay entries with the sentinel (uint32_t)-1
("no override for this field") instead of cur_uid/cur_gid.
Resolve sentinels to cur before the stale-entry removal check
so both sides of the comparison use guest-virtual IDs.
Skip sentinel fields in chown_overlay_apply so a partial chown
does not corrupt the untouched field with a stale value.
fix #136
Summary by cubic
Fixes ID-space mismatches in the chown overlay by evaluating guards in the guest-visible UID/GID space to avoid false no-ops and stale entries. Corrects ownership updates on macOS and with virtualized owners; fixes #136.
Written for commit a124c8d. Summary will update on new commits.