|
| 1 | +From 7c194454e6e4e7c204d8839b2df7c7f8010bf151 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Gao Xiang <hsiangkao@linux.alibaba.com> |
| 3 | +Date: Thu, 19 Feb 2026 09:07:55 +0800 |
| 4 | +Subject: [PATCH] erofs-utils: lib,fuse: fix xattr parsing in the metabox inode |
| 5 | + |
| 6 | +Source kernel commit: 414091322c6363c9283aeb177101e4d7a3819ccd |
| 7 | + |
| 8 | +Forwarded: https://lore.kernel.org/r/20260219010755.1269214-1-hsiangkao@linux.alibaba.com |
| 9 | +Origin: upstream, https://git.kernel.org/xiang/erofs-utils/p/7c194454e6e4 |
| 10 | +Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> |
| 11 | +--- |
| 12 | + include/erofs/internal.h | 1 + |
| 13 | + lib/xattr.c | 7 ++++--- |
| 14 | + 2 files changed, 5 insertions(+), 3 deletions(-) |
| 15 | + |
| 16 | +diff --git a/include/erofs/internal.h b/include/erofs/internal.h |
| 17 | +index e741f1c..671880f 100644 |
| 18 | +--- a/include/erofs/internal.h |
| 19 | ++++ b/include/erofs/internal.h |
| 20 | +@@ -192,6 +192,7 @@ EROFS_FEATURE_FUNCS(48bit, incompat, INCOMPAT_48BIT) |
| 21 | + EROFS_FEATURE_FUNCS(metabox, incompat, INCOMPAT_METABOX) |
| 22 | + EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM) |
| 23 | + EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER) |
| 24 | ++EROFS_FEATURE_FUNCS(shared_ea_in_metabox, compat, COMPAT_SHARED_EA_IN_METABOX) |
| 25 | + EROFS_FEATURE_FUNCS(plain_xattr_pfx, compat, COMPAT_PLAIN_XATTR_PFX) |
| 26 | + EROFS_FEATURE_FUNCS(ishare_xattrs, compat, COMPAT_ISHARE_XATTRS) |
| 27 | + |
| 28 | +diff --git a/lib/xattr.c b/lib/xattr.c |
| 29 | +index d8c7bff..86f2e45 100644 |
| 30 | +--- a/lib/xattr.c |
| 31 | ++++ b/lib/xattr.c |
| 32 | +@@ -1172,7 +1172,7 @@ static int erofs_init_inode_xattrs(struct erofs_inode *vi) |
| 33 | + } |
| 34 | + |
| 35 | + it.buf = __EROFS_BUF_INITIALIZER; |
| 36 | +- erofs_init_metabuf(&it.buf, sbi, false); |
| 37 | ++ erofs_init_metabuf(&it.buf, sbi, erofs_inode_in_metabox(vi)); |
| 38 | + it.pos = erofs_iloc(vi) + vi->inode_isize; |
| 39 | + |
| 40 | + /* read in shared xattr array (non-atomic, see kmalloc below) */ |
| 41 | +@@ -1355,6 +1355,7 @@ static int erofs_xattr_iter_inline(struct erofs_xattr_iter *it, |
| 42 | + return -ENODATA; |
| 43 | + } |
| 44 | + |
| 45 | ++ erofs_init_metabuf(&it->buf, it->sbi, erofs_inode_in_metabox(vi)); |
| 46 | + remaining = vi->xattr_isize - xattr_header_sz; |
| 47 | + it->pos = erofs_iloc(vi) + vi->inode_isize + xattr_header_sz; |
| 48 | + while (remaining) { |
| 49 | +@@ -1390,6 +1391,8 @@ static int erofs_xattr_iter_shared(struct erofs_xattr_iter *it, |
| 50 | + unsigned int i; |
| 51 | + int ret = -ENODATA; |
| 52 | + |
| 53 | ++ erofs_init_metabuf(&it->buf, sbi, |
| 54 | ++ erofs_sb_has_shared_ea_in_metabox(sbi)); |
| 55 | + for (i = 0; i < vi->xattr_shared_count; ++i) { |
| 56 | + it->pos = erofs_pos(sbi, sbi->xattr_blkaddr) + |
| 57 | + vi->xattr_shared_xattrs[i] * sizeof(__le32); |
| 58 | +@@ -1431,7 +1434,6 @@ int erofs_getxattr(struct erofs_inode *vi, const char *name, char *buffer, |
| 59 | + |
| 60 | + it.sbi = vi->sbi; |
| 61 | + it.buf = __EROFS_BUF_INITIALIZER; |
| 62 | +- erofs_init_metabuf(&it.buf, it.sbi, false); |
| 63 | + it.buffer = buffer; |
| 64 | + it.buffer_size = buffer_size; |
| 65 | + it.buffer_ofs = 0; |
| 66 | +@@ -1456,7 +1458,6 @@ int erofs_listxattr(struct erofs_inode *vi, char *buffer, size_t buffer_size) |
| 67 | + |
| 68 | + it.sbi = vi->sbi; |
| 69 | + it.buf = __EROFS_BUF_INITIALIZER; |
| 70 | +- erofs_init_metabuf(&it.buf, it.sbi, false); |
| 71 | + it.buffer = buffer; |
| 72 | + it.buffer_size = buffer_size; |
| 73 | + it.buffer_ofs = 0; |
| 74 | +-- |
| 75 | +2.47.3 |
| 76 | + |
0 commit comments