You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A rootless macOS host cannot chown a file to an arbitrary uid/gid, so
the existing fallback turns the host EPERM into no-op success. Follow-up
stat still returns the host's real owner instead of the value the guest
just chowned to, which trips programs that diff metadata after extraction
(tar --same-owner, cp -p, rsync -a, install -o user, dpkg, Python
shutil.chown + os.stat).
Add a small (dev, ino) -> (uid, gid) overlay keyed by host stat.
sys_fchown{at} record the intent on EPERM and on host success alike,
with the partial-chown -1 sentinel preserving the prior field. The
stat-family wrappers in src/syscall/fs-stat.c consult the overlay once
before translating struct stat into linux_stat[x]_t, so fstat /
newfstatat / statx all pick up the override automatically. The set helper
auto-prunes entries whose final (uid, gid) matches host's current values,
so a guest that resets to the host owner walks away with a clean table.
Host inode reuse is defended by hooks in sys_unlinkat, sys_renameat2,
and sys_close: stat the identity before the operation, and clear the
overlay only when no other path or open fd still references the same
(dev, ino). Forked children inherit the overlay through a new
chown_overlay_{send,recv} on the existing fork IPC socket. The recv
helper reads records into a transient heap buffer before taking the lock
so blocking IO does not serialize sibling stats; it also rejects
out-of-band record counts.
stat is hot. The lock is a pthread_rwlock_t with apply / send taking the
read lock and set / clear / recv taking the write lock; an atomic entry
counter lets apply skip the lock entirely when no overrides exist.
The fork IPC header drops the standalone version field. The first header
word is the protocol identity: bumping FORK_IPC_PROTOCOL_MAGIC
(0x454C464C, "ELFL") replaces what bumping IPC_VERSION used to do, with
one fewer field on the wire and one fewer concept in the code.
Close#59
0 commit comments