[PATCH] erofs-utils: lib: fix xattr crash in rebuild path when source has xattr
Gao Xiang
hsiangkao at linux.alibaba.com
Tue Mar 3 02:22:23 AEDT 2026
On 2026/3/2 21:03, lishixian wrote:
> When rebuilding from source EROFS images, erofs_read_xattrs_from_disk()
> is called for inodes that have xattr. At that point inode->sbi points to
> the source image's sbi, which is opened read-only and never gets
> erofs_xattr_init(), so sbi->xamgr is NULL. get_xattritem(sbi) then
> dereferences xamgr and crashes with SIGSEGV.
>
> Fix by using the build target's xamgr when initializing src's sbi.
>
> Reported-by: Yixiao Chen <489679970 at qq.com>
> Fixes: https://github.com/erofs/erofs-utils/issues/42
> Signed-off-by: lishixian <lishixian8 at huawei.com>
> Reviewed-by: Yifan Zhao <zhaoyifan28 at huawei.com>
> ---
> lib/rebuild.c | 1 +
> mkfs/main.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/lib/rebuild.c b/lib/rebuild.c
> index f89a17c..f1e79c1 100644
> --- a/lib/rebuild.c
> +++ b/lib/rebuild.c
> @@ -437,6 +437,7 @@ int erofs_rebuild_load_tree(struct erofs_inode *root, struct erofs_sb_info *sbi,
> erofs_err("failed to read superblock of %s", fsid);
> return ret;
> }
> + sbi->xamgr = g_sbi.xamgr;
`g_sbi` shouldn't be used in `lib/`, I think for this particula
one, we should set in the caller instead:
list_for_each_entry(src, &rebuild_src_list, list) {
src->xamgr = g_sbi.xamgr;
ret = erofs_rebuild_load_tree(root, src, datamode);
src->xamgr = NULL;
...
}
Thanks,
Gao Xiang
More information about the Linux-erofs
mailing list