Bug 2397782

Summary: `cp --preserve=xattr a b` now fails when copying on a NFSv4
Product: [Fedora] Fedora Reporter: Lukáš Zaoral <lzaoral>
Component: coreutilsAssignee: Lukáš Zaoral <lzaoral>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 42CC: admiller, jamartis, kdudka, kzak, lzaoral, nixuser, ovasik, p, svashisht, vmihalko
Target Milestone: ---Flags: lzaoral: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lukáš Zaoral 2025-09-24 11:19:39 UTC
After some fix in kernel, `listxattr(3)` now lists `security.selinux` but this attribute cannot be set because it is apparently read-only and synthesised by the kernel:

# strace -s 100 --trace='/xattr' cp --preserve=xattr a b
flistxattr(3, NULL, 0)                  = 33
flistxattr(3, "system.nfs4_acl\0security.selinux\0", 33) = 33
fgetxattr(3, "system.nfs4_acl", NULL, 0) = 80
fgetxattr(3, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\207\0\0\0\6OWNER@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\6GROUP@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\tEVERYONE@\0\0", 80) = 80
fsetxattr(4, "system.nfs4_acl", "\0\0\0\3\0\0\0\0\0\0\0\0\0\26\1\207\0\0\0\6OWNER@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\6GROUP@\0\0\0\0\0\0\0\0\0\0\0\22\0\201\0\0\0\tEVERYONE@\0\0", 80, 0) = 0
fgetxattr(3, "security.selinux", NULL, 0) = 27
fgetxattr(3, "security.selinux", "system_u:object_r:nfs_t:s0", 27) = 27
fsetxattr(4, "security.selinux", "system_u:object_r:nfs_t:s0", 27, 0) = -1 EOPNOTSUPP (Operation not supported)
cp: setting attributes for 'b': Operation not supported

Well, the error itself is correct, `fsetxattr` failed, and `--preserve=mode` can be used as a workaround if the reason for using `--preserve=xattr` were NFSv4 ACLs,
but it still looks quite annoying.  The destination file will have `system_u:object_r:nfs_t:s0` synthesised anyway so despite the error it will end up with the same
xattrs as the source...

Originally reported in bz2397467#c5.