Skip to contentSkip to conversation

erofs-utils: xattr: skip xattrs with unidentified "system." prefix

PATCH In review Weizhao Ouyang 2 participants 2 messages Apr 20, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 erofs-utils: xattr: skip xattrs with unidentified "system." prefix

Skip xattrs with unidentified "system." prefix to avoid ENODATA error. Such as building AOSP on NFSv4 servers.

---
 include/erofs/xattr.h |  6 ++++++
 lib/xattr.c           | 12 ++++++++++++
 2 files changed, 18 insertions(+)
include/erofs/xattr.h +6 -0
index 9efadc5e5e80..de078a5eb08a 100644
@@ -41,6 +41,12 @@ static inline unsigned int xattrblock_offset(unsigned int xattr_id)
 	(_size - sizeof(struct erofs_xattr_ibody_header)) / \
 	sizeof(struct erofs_xattr_entry) + 1; })
 
+#ifndef XATTR_SYSTEM_PREFIX
+#define XATTR_SYSTEM_PREFIX	"system."
+#endif
+#ifndef XATTR_SYSTEM_PREFIX_LEN
+#define XATTR_SYSTEM_PREFIX_LEN (sizeof(XATTR_SYSTEM_PREFIX) - 1)
+#endif
 #ifndef XATTR_USER_PREFIX
 #define XATTR_USER_PREFIX	"user."
 #endif
lib/xattr.c +12 -0
index 6034e7b6b4eb..7c776330bdaa 100644
@@ -288,6 +288,18 @@ static bool erofs_is_skipped_xattr(const char *key)
 	if (cfg.sehnd && !strcmp(key, XATTR_SECURITY_PREFIX "selinux"))
 		return true;
 #endif
+
+	/* skip xattrs with unidentified "system." prefix */
+	if (!strncmp(key, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) {
+		if (!strcmp(key, XATTR_NAME_POSIX_ACL_ACCESS) ||
+		    !strcmp(key, XATTR_NAME_POSIX_ACL_DEFAULT)) {
+			return false;
+		} else {
+			erofs_warn("skip unidentified xattr: %s", key);
+			return true;
+		}
+	}
+
 	return false;
 }
 
Signature · 1 line
2.25.1