overlay: fix EPERM panic on directory rename and add noxattr - #14073
overlay: fix EPERM panic on directory rename and add noxattr#14073anthops wants to merge 3 commits into
Conversation
Writing tests for the noxattr overlay support and EXDEV in RenameAt revealed that the previous implementation unconditionally set the opaque xattr on every directory rename, diverging from the Linux kernel's ovl_rename_upper() behaviour. Tightened the RenameAt directory rename logic to match Linux: - In noxattr mode, reject merge/lower directory renames with EXDEV since gVisor does not support redirect_dir (see ovl_rename_start() -> ovl_can_move()). - Only set the opaque xattr on pure-upper directories when newParent has lower layers that could show through (see ovl_rename_upper() -> ovl_set_opaque_xerr()). Implemented test: - Extracted OverlayDirRenameInUserNS test helper in mount.cc and created OverlayfsDirectoryRenameInUserNamespaceNoxattrFallback test (no userxattr, rename returns EXDEV). - Changed noxattr probe warning to Debugf to avoid leak-check failures.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@anthops here is what Claude had to say: I fetched the PR, read the changes in context, and re-ran the Linux experiments against the specific claims it makes. The direction is right — mount-time probe, 1. The probe both flips the xattr prefix and sets
|
Renaming a directory within an overlay whose upper layer is tmpfs, from within a nested user namespace (e.g.
unshare -Urm), caused the sandbox to panic with:This occurred becasue
RenameAtunconditionally attempted to settrusted.overlay.opaqueon the renamed directory after the rename, and panicked on failure. This is becausetrusted.*xattrs requireCAP_SYS_ADMINin the init user namespace, which is unavailable.On native Linux, the overlay filesystem probes xattr support at mount time, setting
ofs->noxattron failure. Directory renames that require the opaque xattr returnEXDEV, allowing userspace tools likemvto fall back to copy + delete.Changes
trusted.overlay.*/user.overlay.*xattr support, similar to Linux'sovl_make_workdir().newParenthas lower layers that could show through, matching Linux's behaviour inovl_rename_upper().checkSetXattr, which returnsEXDEVin noxattr mode, similar to Linux'sovl_set_opaque_xerr.EXDEV. This is because gVisor does not implementredirect_dir(seeovl_set_redirect). Without redirect support, there is no way to track where a merge directory moved to after a rename, so we instruct the userspace tool to fall back here.OverlayfsDirectoryRenameInUserNamespaceNoxattrFallbacktest tomount.ccthat tests theEXDEVreturnFixes #14033