Skip to contentSkip to conversation

erofs-utils: mkfs: limit total shared xattrs of a single inode

PATCH Superseded Gao Xiang 1 participant 2 messages Sep 20, 2023 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: mkfs: limit total shared xattrs of a single inode

Don't output more than 255 shared xattrs for a single inode due to the EROFS on-disk format limitation.

Fixes 116ac0a254fc ("erofs-utils: introduce shared xattr support")
---
 lib/xattr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
lib/xattr.c +6 -2
index 790547c..1ed796b 100644
@@ -665,6 +665,7 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode)
 	int ret;
 	struct inode_xattr_node *node;
 	struct list_head *ixattrs = &inode->i_xattrs;
+	unsigned int h_shared_count;
 
 	if (list_empty(ixattrs)) {
 		inode->xattr_isize = 0;
@@ -672,11 +673,13 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode)
 	}
 
 	/* get xattr ibody size */
+	h_shared_count = 0;
 	ret = sizeof(struct erofs_xattr_ibody_header);
 	list_for_each_entry(node, ixattrs, list) {
 		struct xattr_item *item = node->item;
 
-		if (item->shared_xattr_id >= 0) {
+		if (item->shared_xattr_id >= 0 || h_shared_count < UCHAR_MAX) {
+			++h_shared_count;
 			ret += sizeof(__le32);
 			continue;
 		}
@@ -980,7 +983,8 @@ char *erofs_export_xattr_ibody(struct erofs_inode *inode)
 		list_del(&node->list);
 
 		/* move inline xattrs to the onstack list */
-		if (item->shared_xattr_id < 0) {
+		if (item->shared_xattr_id < 0 ||
+		    header->h_shared_count >= UCHAR_MAX) {
 			list_add(&node->list, &ilst);
 			continue;
 		}
Signature · 1 line
2.39.3
author
#1 lore raw

PATCH RESEND 1/1 erofs-utils: mkfs: limit total shared xattrs of a single inode

Don't output more than 255 shared xattrs for a single inode due to the EROFS on-disk format limitation.

Fixes 116ac0a254fc ("erofs-utils: introduce shared xattr support")
---
 lib/xattr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
lib/xattr.c +6 -2
index 790547c..1ed796b 100644
@@ -665,6 +665,7 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode)
 	int ret;
 	struct inode_xattr_node *node;
 	struct list_head *ixattrs = &inode->i_xattrs;
+	unsigned int h_shared_count;
 
 	if (list_empty(ixattrs)) {
 		inode->xattr_isize = 0;
@@ -672,11 +673,13 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode)
 	}
 
 	/* get xattr ibody size */
+	h_shared_count = 0;
 	ret = sizeof(struct erofs_xattr_ibody_header);
 	list_for_each_entry(node, ixattrs, list) {
 		struct xattr_item *item = node->item;
 
-		if (item->shared_xattr_id >= 0) {
+		if (item->shared_xattr_id >= 0 && h_shared_count < UCHAR_MAX) {
+			++h_shared_count;
 			ret += sizeof(__le32);
 			continue;
 		}
@@ -980,7 +983,8 @@ char *erofs_export_xattr_ibody(struct erofs_inode *inode)
 		list_del(&node->list);
 
 		/* move inline xattrs to the onstack list */
-		if (item->shared_xattr_id < 0) {
+		if (item->shared_xattr_id < 0 ||
+		    header->h_shared_count >= UCHAR_MAX) {
 			list_add(&node->list, &ilst);
 			continue;
 		}
Signature · 1 line
2.39.3