Bug 1297464 - mv data loss when destination directory appears in source list more than once
mv data loss when destination directory appears in source list more than once
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
23
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Ondrej Vasik
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-11 10:21 EST by Yeasah Pell
Modified: 2016-01-15 18:24 EST (History)
7 users (show)

See Also:
Fixed In Version: coreutils-8.24-5.fc23
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-15 18:24:06 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
proposed upstream fix (7.37 KB, patch)
2016-01-12 07:55 EST, Pádraig Brady
no flags Details | Diff

  None (edit)
Description Yeasah Pell 2016-01-11 10:21:44 EST
Description of problem:
When mv is mistakenly given arguments including a directory listed at least twice as a source as well as the destination, it will destroy that directory and everything in it will be lost.

Version-Release number of selected component (if applicable):
coreutils-8.24-4.fc23.x86_64

How reproducible:
Trivially reproducible with steps

Steps to Reproduce:
1. mkdir test
2. mv test test test

Actual results:
mv: cannot move 'test' to a subdirectory of itself, 'test/test'
mv: warning: source directory 'test' specified more than once
(and the directory and all contents are destroyed)

Expected results: (per EPEL7)
mv: cannot move 'test' to a subdirectory of itself, 'test/test'
mv: will not create hard link 'test/test' to directory 'test/test'
(and the directory remains unchanged with contents intact)


Additional info:
Comment 1 Pádraig Brady 2016-01-11 13:15:23 EST
Ouch, this looks like due to the 'return true' at:
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.23-31-g90aa291

I'll fix this upstream this evening.
Comment 2 Pádraig Brady 2016-01-11 13:37:59 EST
This avoids the issue at least.
Full patch coming up...

@@ -2281,7 +2283,8 @@ copy_internal (char const *src_name, char const *dst_name,
               /* We only do backups in move mode and for non dirs,
                  and in move mode this won't be the issue as the source will
                  be missing for subsequent attempts.
-                 There we just warn and return here.  */
+                 Therefore we just warn and return here.  */
+              *copy_into_self = true;
               return true;
             }
           else if (x->dereference == DEREF_ALWAYS
Comment 3 Pádraig Brady 2016-01-12 07:55 EST
Created attachment 1113926 [details]
proposed upstream fix
Comment 4 Ondrej Vasik 2016-01-12 18:12:20 EST
Thanks for the patch and quick fix - there is a typo in the NEWS entry (no londer). Other than that, looks fine, I'll apply this to rawhide and f23...well - later today ;).
Comment 5 Fedora Update System 2016-01-13 07:36:51 EST
coreutils-8.24-5.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-477caff2e3
Comment 6 Fedora Update System 2016-01-14 06:25:42 EST
coreutils-8.24-5.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-477caff2e3
Comment 7 Fedora Update System 2016-01-15 18:24:01 EST
coreutils-8.24-5.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.