Skip to content

mv: cross-device directory move writes through a symlink that appears in the destination #14991

Description

@abendrothj

When a directory is moved across filesystems, mv falls back to copying it, and each destination entry is created by joining a path, with regular files going through fs::copy. If a symlink appears at one of those names in the destination while the copy is running, it is followed, so that file's content (and the truncation before it) lands wherever the symlink points.

To reproduce, move a directory with many files from one filesystem to another (e.g. into /dev/shm) while another process keeps creating symlinks at the destination names, pointing at a file outside the tree. That file ends up overwritten with the source content.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions