aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGao Xiang <hsiangkao@linux.alibaba.com>2023-09-21 03:02:20 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-09-21 03:05:34 +0800
commit96c4a82a7b247d69833d2fc174cc4e15c84f03d1 (patch)
treef1e2e55729f988e2dc084057428ac0b9ce38a0ee
parentcf3b15d8beb5aff3e88625696d1627a74c2adb94 (diff)
downloaderofs-utils-96c4a82a7b247d69833d2fc174cc4e15c84f03d1.tar.gz
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") Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20230920190220.1837650-1-hsiangkao@linux.alibaba.com
-rw-r--r--lib/xattr.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/xattr.c b/lib/xattr.c
index 790547c..6c8ebf4 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -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;
}