Bug 358701

Summary: /bin/cp can cause data loss on filesystems that are not SELinux aware
Product: [Fedora] Fedora Reporter: Elliot Lee <sopwith>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: low    
Version: rawhideCC: twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-30 18:05:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to fix this problem none

Description Elliot Lee 2007-10-30 17:48:11 UTC
Description of problem:

On a filesystem such as NFS that doesn't know how to store SELinux metadata,
/bin/cp can create empty target files due to incorrect error handling.

Version-Release number of selected component (if applicable):
coreutils-6.9-6.fc8

How reproducible:
100%

Steps to Reproduce:
1. Go to an NFS-mounted directory that has a non-empty file named 'file1'.
2. Run 'cp -av file1 file2'.
3. Run 'cp -av file1 file2' again.
  
Actual results:
file2 is empty

Expected results:
file2 has same contents as file1

Additional info:

Patch is attached that fixes this particular case. However, I would almost argue
that all errors generated by fsetfilecon() should be ignored (and not just
EOPNOTSUPP), simply because they're not fatal, and because truncating the user's
files to zero-length is a really bad outcome for a basic utility like /bin/cp.

Comment 1 Elliot Lee 2007-10-30 17:48:12 UTC
Created attachment 243681 [details]
Patch to fix this problem

Comment 2 Ondrej Vasik 2007-10-30 18:05:59 UTC
That is more workaround than patch. Anyway - I have a fix for that - so this bug
is duplicate of #219900 (patch will hopefully make it into F8 final)

*** This bug has been marked as a duplicate of 219900 ***