listxattr() should return ENOTSUP for sysfs / tmpfs entries, not 0
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Older coreutils was less efficient and always called getxattr("security.selinux"), and thus shows the SELinux context as expected:
$ coreutils-9.3/src/ls -lZd /run/initramfs drwxr-xr-x. 3 root root system_u:object_r:tmpfs_t:s0 60 Apr 19 14:52 /run/initramfs $ coreutils-9.3/src/ls -lZd /sys/block drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0 0 Apr 23 12:54 /sys/block
However newer coreutils is more efficient, and does not call getxattr() if listxattr() returns 0 indicating that there are no xattrs.
$ coreutils-9.7/src/ls -lZd /run/initramfs drwxr-xr-x 3 root root ? 60 Apr 19 14:52 /run/initramfs $ coreutils-9.7/src/ls -lZd /sys/block drwxr-xr-x 2 root root ? 0 Apr 23 12:54 /sys/block
I also noticed the same issue with the exa utility for example.
For coreutils to maintain efficient processing and to fix the issue centrally, it would be more correct for listxattr() to return ENOTSUP,
in which case ls will try the getxattr() call and operate as expected. Otherwise I can't see a way for coreutils to be both efficient and always correct.
I'm currently testing on kernel 6.14.2-300.fc42.x86_64
thanks,
Padraig
Re: bug#77597: listxattr() should return ENOTSUP for sysfs / tmpfs entries, not 0
Quoted 16 lines · Pádraig Brady
Older coreutils was less efficient and always called
getxattr("security.selinux"), and thus shows the SELinux context as expected:$ coreutils-9.3/src/ls -lZd /run/initramfs drwxr-xr-x. 3 root root system_u:object_r:tmpfs_t:s0 60 Apr 19 14:52 /run/initramfs $ coreutils-9.3/src/ls -lZd /sys/block drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0 0 Apr 23 12:54 /sys/blockHowever newer coreutils is more efficient, and does not call
getxattr()iflistxattr()returns 0 indicating that there are no xattrs.$ coreutils-9.7/src/ls -lZd /run/initramfs drwxr-xr-x 3 root root ? 60 Apr 19 14:52 /run/initramfs $ coreutils-9.7/src/ls -lZd /sys/block drwxr-xr-x 2 root root ? 0 Apr 23 12:54 /sys/block
Quoted 7 lines
I also noticed the same issue with the exa utility for example.
For coreutils to maintain efficient processing and to fix the issue centrally, it would be more correct forlistxattr()to return ENOTSUP,
in which case ls will try thegetxattr()call and operate as expected. Otherwise I can't see a way for coreutils to be both efficient and always correct.I'm currently testing on kernel 6.14.2-300.fc42.x86_64
FYI this should be addressed with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8b0ba61d
cheers,
Pádraig
Re: bug#77597: listxattr() should return ENOTSUP for sysfs / tmpfs entries, not 0
Quoted 2 lines · Pádraig Brady
FYI this should be addressed with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8b0ba61d
Thanks for letting me know, as this led me to further testing that found some other kernel bugs in this area, possibly introduced by that kernel commit. Please see:
"flistxattr with right size wrongly fails with ERANGE, breaking 'cp -a' etc" <https://bugzilla.redhat.com/show_bug.cgi?id=2369561>
The email thread starting at "[PATCH] Fix listxattr-related races and stack overflows" <https://lists.nongnu.org/archive/html/acl-devel/2025-05/msg00003.html>.