fix(fs): handle symlinks in overlay rename and copy#1014
Merged
Conversation
OverlayFs::rename and copy used read_file which intentionally doesn't follow symlinks (TM-ESC-002), causing silent failures when renaming or copying symlinks. Now detects symlinks via stat and preserves them as symlinks using read_link + symlink. Same fix applied to MountableFs cross-mount rename/copy.
Document the symlink rename/copy vulnerability in overlay and mountable filesystems. OverlayFs::rename used read_file which doesn't follow symlinks, silently failing. Now fixed and tracked as TM-ESC-016.
Cover MountableFs cross-mount paths for symlink rename and copy to ensure symlinks are preserved across filesystem boundaries.
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.
Summary
OverlayFs::renameandcopyusedread_file()which intentionally doesn't follow symlinks (TM-ESC-002), causing silent failures when operating on symlinks. Now detects symlinks viastat()and preserves them usingread_link()+symlink().MountableFscross-mount rename/copy paths.Test plan
overlay_rename_preserves_symlink— rename symlink in upper layeroverlay_rename_symlink_from_lower_layer— rename symlink from lower to upper (CoW)overlay_copy_preserves_symlink— copy preserves symlink typesymlink_rename_cannot_escape_mount_via_read— read_file on renamed symlink still blockedbash_mv_symlink_in_overlay— end-to-end mv + readlink in bash session