Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Sep 2023 16:44:15 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0f07f838d059 - releng/14.0 - linux(4): Return ENOTSUP from listxattr instead of EPERM
Message-ID:  <202309121644.38CGiFeJ071205@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.0 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=0f07f838d059a2b56c33cd6340f0a172e8d97af7

commit 0f07f838d059a2b56c33cd6340f0a172e8d97af7
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-09-05 08:52:27 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-09-12 16:43:10 +0000

    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.
    
    Approved by:            re (gjb)
    Reported by:            zirias
    Tested by:              zirias
    MFC after:              1 week
    
    (cherry picked from commit 11e37048db35d7fcfc285b867965de1aeefec2c8)
    (cherry picked from commit e975d1b72507def7a699adf1cb38c68b48d80f51)
---
 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 71d7ae58439e..6979fff9c82d 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];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309121644.38CGiFeJ071205>