Re: Possible issue with linux xattr support?

From: Felix Palmen <zirias_at_freebsd.org>
Date: Mon, 04 Sep 2023 14:03:54 UTC
* Felix Palmen <zirias@freebsd.org> [20230904 15:39]:
> For some reason (I still have to try to get more information about it,
> will do soon), something else is broken now. While install from GNU
> coreutils works fine, some build systems use 'cp -p' to install files
> instead, which now fails with:
> 
> | cp: preserving permissions for [...]: Operation not permitted

The issue seems to be with listing attributes:

| root@15-default:/wrkdirs/usr/ports/x11/linuxsrc-libxcb/work/libxcb-1.15/doc # truss /compat/linux/bin/cp -pR ./tutorial '/wrkdirs/usr/ports/x11/linuxsrc-libxcb/work/stage/compat/linux/usr/share/doc/libxcb/' 2>&1 | grep xattr
| linux_flistxattr(0x4,0x0,0x0)                    ERR#-1 'Operation not permitted'
| linux_flistxattr(0x4,0x0,0x0)                    ERR#-1 'Operation not permitted'
| linux_llistxattr(0xffffffffcdd9,0x0,0x0)         ERR#-1 'Operation not permitted'

The following q&d patch makes it work again:

#v+
diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c
index 74b47f1cbaec..0b5af084b1b1 100644
--- a/sys/compat/linux/linux_xattr.c
+++ b/sys/compat/linux/linux_xattr.c
@@ -198,7 +198,7 @@ listxattr(struct thread *td, struct listxattr_args *args)
        if (error == 0)
                td->td_retval[0] = cnt;
        free(data, M_LINUX);
-       return (error_to_xattrerror(attrnamespace, error));
+       return (error_to_xattrerror(EXTATTR_NAMESPACE_SYSTEM, error));
 }
 
 int
#v-

I think this makes sense, because listxattr iterates over all
namespaces, so there's no sane way to know whether the EPERM was caused
by trying to access "system" or something else.

Cheers, Felix

-- 
 Felix Palmen <zirias@FreeBSD.org>     {private}   felix@palmen-it.de
 -- ports committer --                     {web}  http://palmen-it.de
 {pgp public key}  http://palmen-it.de/pub.txt
 {pgp fingerprint} 6936 13D5 5BBF 4837 B212  3ACC 54AD E006 9879 F231