Skip to content

mv: moving a special file across filesystems deletes the destination on failure #13145

Open

Description

@sylvestre

Reported by @HackingRepo via security advisory GHSA-xw28-j282-p74c. We don't consider this a security issue, so we're tracking it as a regular bug.

Description
When mv falls back to the copy path (cross-filesystem / EXDEV) for a special file (e.g. a socket) and the operation fails, the existing destination is removed entirely, causing data loss.

Repro (socket on tmpfs, dest on a different filesystem to force the copy path)

$ echo important > a
$ mv /path/on/tmpfs/sock a
mv: Permission denied (os error 13)
$ cat a
cat: a: No such file or directory      # 'a' was deleted

GNU leaves a in place (recreated as a socket) rather than deleting it.

Expected: on a failed cross-fs move of a special file, the existing destination must not be destroyed.
Actual: destination is removed, original contents lost.

(Also: the error carries (os error 13) and lacks the 'src' to 'dest' context GNU prints.)

Activity

  1. added a commit that references this issue on Aug 17, 2026
    eaf69db
  2. added 2 commits that reference this issue on Sep 22, 2026
    d74ffb3
    f707bea
  3. added 5 commits that reference this issue on Oct 1, 2026
    91c2b59
    6b578bd
    5bf7402
    1a1e170
    fd92ccb
  4. added 3 commits that reference this issue on Nov 16, 2026
    3b9d461
    1d8022b
    3b9cf1f
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