From 11e37048db35d7fcfc285b867965de1aeefec2c8 Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Tue, 5 Sep 2023 11:52:27 +0300 Subject: [PATCH] linux(4): Return ENOTSUP from listxattr instead of EPERM FreeBSD does not permits manipulating extended attributes in the system namespace by unprivileged accounts, even if account has appropriate privileges to access filesystem object. In Linux the system namespace is used to preserve posix acls. Some Gnu coreutils binaries uses posix acls, eg, install, ls, cp. And fails if we unexpectedly return EPERM error from xattr system calls. In the other hands, in Linux read and write access to the system namespace depend on the policy implemented for each filesystem, so we'll mimics we're a filesystem that prohibits this for unpriveleged accounts. Reported by: zirias Tested by: zirias MFC after: 1 week --- sys/compat/linux/linux_xattr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c index 71d7ae58439..6979fff9c82 100644 --- a/sys/compat/linux/linux_xattr.c +++ b/sys/compat/linux/linux_xattr.c @@ -165,6 +165,8 @@ listxattr(struct thread *td, struct listxattr_args *args) error = kern_extattr_list_fd(td, args->fd, attrnamespace, &auio); rs = sz - auio.uio_resid; + if (error == EPERM) + break; if (error != 0 || rs == 0) continue; prefix = extattr_namespace_names[attrnamespace];