[PATCH 1/3] erofs-utils: lib: ignore xattr prefixes if feature is off

Yifan Zhao <[email protected]>
Newsgroups org.ozlabs.lists.linux-erofs
Message-ID <[email protected]>
Ignore xattr_prefix_{count,start} and do not validate the inode-sharing
prefix id without INCOMPAT_XATTR_PREFIXES bit set. This keeps stale
superblock bytes from enabling long xattr prefix decoding on images
that did not declare the feature.

Assisted-by: Codex:GPT-5.5
Signed-off-by: Yifan Zhao <[email protected]>
---
 lib/super.c | 3 ++-
 lib/xattr.c | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/super.c b/lib/super.c
index c21d5ad..899d51a 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -149,7 +149,8 @@ int erofs_read_superblock(struct erofs_sb_info *sbi)
 	sbi->build_time = le32_to_cpu(dsb->build_time);
 
 	memcpy(&sbi->uuid, dsb->uuid, sizeof(dsb->uuid));
-	if (erofs_sb_has_ishare_xattrs(sbi)) {
+	if (erofs_sb_has_ishare_xattrs(sbi) &&
+	    erofs_sb_has_xattr_prefixes(sbi)) {
 		if (dsb->ishare_xattr_prefix_id >= sbi->xattr_prefix_count) {
 			erofs_err("invalid ishare xattr prefix id %d",
 				  dsb->ishare_xattr_prefix_id);
diff --git a/lib/xattr.c b/lib/xattr.c
index 1891ac3..6093572 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -1547,6 +1547,11 @@ int erofs_xattr_prefixes_init(struct erofs_sb_info *sbi)
 	int ret = 0, i, len;
 	void *buf;
 
+	if (!erofs_sb_has_xattr_prefixes(sbi)) {
+		sbi->xattr_prefix_count = 0;
+		return 0;
+	}
+
 	if (!sbi->xattr_prefix_count)
 		return 0;
 
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.