[Bug 266112] Capsicum extended attributes test failing on ZFS

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 30 Aug 2022 04:46:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266112

            Bug ID: 266112
           Summary: Capsicum extended attributes test failing on ZFS
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: tests
          Assignee: testing@FreeBSD.org
          Reporter: sigsys@gmail.com

sys/capsicum/functional:test_unprivileged (internal test
Capability.ExtendedAttributesIfAvailableForked) fails when running with a ZFS
/tmp since OpenZFS started rejecting attribute names with certain prefixes.

It uses compatibility wrappers for the Linux syscalls.  They're only ever
called with "user.*" attribute names, and they always assume that the user
namespace is to be used, but they don't bother stripping the prefix from the
name passed the FreeBSD syscalls.

diff --git i/contrib/capsicum-test/syscalls.h
w/contrib/capsicum-test/syscalls.h
index 592a1677e1f1..3ea8803c2f64 100644
--- i/contrib/capsicum-test/syscalls.h
+++ w/contrib/capsicum-test/syscalls.h
@@ -47,16 +47,29 @@ inline int bogus_mount_() {

 /* Mappings for extended attribute functions */
 #include <sys/extattr.h>
+#include <errno.h>
+static const char *fbsd_extattr_skip_prefix(const char *p) {
+  if (*p++ == 'u' && *p++ == 's' && *p++ == 'e' && *p++ == 'r' && *p++ == '.')
+    return p;
+  errno = EINVAL;
+  return NULL;
+}
 inline ssize_t flistxattr_(int fd, char *list, size_t size) {
   return extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, list, size);
 }
 inline ssize_t fgetxattr_(int fd, const char *name, void *value, size_t size)
{
+  if (!(name = fbsd_extattr_skip_prefix(name)))
+    return -1;
   return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size);
 }
 inline int fsetxattr_(int fd, const char *name, const void *value, size_t
size, int) {
+  if (!(name = fbsd_extattr_skip_prefix(name)))
+    return -1;
   return extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, name, value, size);
 }
 inline int fremovexattr_(int fd, const char *name) {
+  if (!(name = fbsd_extattr_skip_prefix(name)))
+    return -1;
   return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name);
 }

-- 
You are receiving this mail because:
You are the assignee for the bug.