erofs-utils: Compression with -Eall-fragments segfaults on 1.8.2
Hi,
Version 1.8.2 has a reproducible segfault with "-E all-fragments" (testing on Fedora 40). When compressing the install image, it consistently hangs on a firmware file:
Quoted 4 lines
sudo dnf -y install erofs-utils
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/images/install.img
sudo mount install.img /mnt
sudo mkfs.erofs -z zstd -E all-fragments erofs.img /mnt
If you isolate just that firmware directory instead of the whole image, it will segfault:
Quoted 1 line
mkfs.erofs -z zstd -E all-fragments erofs.img
/mnt/usr/lib/firmware/nvidia/ga102/gsp
It happens with all compressors I've tried, but adding "dedupe" works around it. Is there any change I should test? Let me know if you need additional information.
Thanks.
David
Originally reported in: https://bugzilla.redhat.com/2318138
Hi David,
Quoted 11 lines · David Michael
Hi,
Version 1.8.2 has a reproducible segfault with "-E all-fragments" (testing on Fedora 40). When compressing the install image, it consistently hangs on a firmware file:
Quoted 4 lines
sudo dnf -y install erofs-utils
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/images/install.img
sudo mount install.img /mnt
sudo mkfs.erofs -z zstd -E all-fragments erofs.img /mnt
Quoted 8 lines
If you isolate just that firmware directory instead of the whole image, it will segfault:
Quoted 1 line
mkfs.erofs -z zstd -E all-fragments erofs.img
/mnt/usr/lib/firmware/nvidia/ga102/gspIt happens with all compressors I've tried, but adding "dedupe" works around it. Is there any change I should test? Let me know if you need additional information.
Thanks for the report, I will look into that.
Thanks,
Gao Xiang
Quoted 6 lines
Thanks.
David
Originally reported in: https://bugzilla.redhat.com/2318138
Quoted 17 lines · Gao Xiang
Hi David,
Quoted 14 lines · David Michael
Hi,
Version 1.8.2 has a reproducible segfault with "-E all-fragments" (testing on Fedora 40). When compressing the install image, it consistently hangs on a firmware file:
Quoted 4 lines
sudo dnf -y install erofs-utils
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/images/install.img
sudo mount install.img /mnt
sudo mkfs.erofs -z zstd -E all-fragments erofs.img /mntIf you isolate just that firmware directory instead of the whole image, it will segfault:
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
mkfs.erofs -z zstd -E all-fragments erofs.img
/mnt/usr/lib/firmware/nvidia/ga102/gspIt happens with all compressors I've tried, but adding "dedupe" works around it. Is there any change I should test? Let me know if you need additional information.
Thanks for the report, I will look into that.
I've submited a fix for this,
https://lore.kernel.org/r/[email protected]
The original one is a SquashFS xz image:
Compression xz
Dictionary size 131072
Filters selected: x86
Block size 131072
Inodes are compressed
Data is compressed
Fragments are compressed
..
so the results are:
618008576 install.img
621953024 install.erofs (mkfs.erofs -zlzma -C131072 -Eall-fragments,ztailpacking -T0)
Since EROFS doesn't support metadata compression for now, the difference is just out of compressed metadata.
Thanks,
Gao Xiang
Quoted 11 lines
Thanks,
Gao XiangQuoted 6 lines
Thanks.
David
Originally reported in: https://bugzilla.redhat.com/2318138
Quoted 20 lines · Gao Xiang
Quoted 19 lines · Gao Xiang
Hi David,
Quoted 16 lines · David Michael
Hi,
Version 1.8.2 has a reproducible segfault with "-E all-fragments" (testing on Fedora 40). When compressing the install image, it consistently hangs on a firmware file:
Quoted 4 lines
sudo dnf -y install erofs-utils
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/images/install.img
sudo mount install.img /mnt
sudo mkfs.erofs -z zstd -E all-fragments erofs.img /mntIf you isolate just that firmware directory instead of the whole image, it will segfault:
Quoted 1 line
mkfs.erofs -z zstd -E all-fragments erofs.img
/mnt/usr/lib/firmware/nvidia/ga102/gsp
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
It happens with all compressors I've tried, but adding "dedupe" works around it. Is there any change I should test? Let me know if you need additional information.
Thanks for the report, I will look into that.
I've submited a fix for this,
https://lore.kernel.org/r/[email protected]
Thanks, this does fix the issue for me. I'll apply it to the Fedora package unless you want me to wait for another tag.
David
Quoted 25 lines · David Michael
Quoted 24 lines · Gao Xiang
Quoted 23 lines · Gao Xiang
Hi David,
Quoted 19 lines · David Michael
Hi,
Version 1.8.2 has a reproducible segfault with "-E all-fragments" (testing on Fedora 40). When compressing the install image, it consistently hangs on a firmware file:
Quoted 4 lines
sudo dnf -y install erofs-utils
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/images/install.img
sudo mount install.img /mnt
sudo mkfs.erofs -z zstd -E all-fragments erofs.img /mntIf you isolate just that firmware directory instead of the whole image, it will segfault:
Quoted 1 line
mkfs.erofs -z zstd -E all-fragments erofs.img
/mnt/usr/lib/firmware/nvidia/ga102/gspIt happens with all compressors I've tried, but adding "dedupe" works around it. Is there any change I should test? Let me know if you need additional information.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Thanks for the report, I will look into that.
I've submited a fix for this,
https://lore.kernel.org/r/[email protected]Thanks, this does fix the issue for me. I'll apply it to the Fedora package unless you want me to wait for another tag.
I guess I won't tag a new version for this (but I suspect it will need another 1.8.3 in the future), so feel free to apply directly :-)
Thanks,
Gao Xiang
Quoted 2 lines
David
PATCH 1/1 erofs-utils: mkfs: fix `-Eall-fragments` for multi-threaded compression
In reply to David MichaelIf -Eall-fragments is specified when multi-threaded compression is enabled, it should only apply to the packed inode instead of other real inodes for now.
--- lib/compress.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
lib/compress.c +7 -6
@@ -1453,12 +1453,8 @@ void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos) inode->idata_size =0 ; inode->fragment_size =0 ; -if (z_erofs_mt_enabled) { - ictx =malloc (sizeof (*ictx)); -if (!ictx) -return ERR_PTR (-ENOMEM ); - ictx->fd =dup (fd); - }else { +if (!z_erofs_mt_enabled || + (cfg.c_all_fragments && !erofs_is_packed_inode (inode))) {#ifdef EROFS_MT_ENABLED pthread_mutex_lock (&g_ictx.mutex);if (g_ictx.seg_num)
@@ -1468,6 +1464,11 @@ void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos)#endif ictx = &g_ictx; ictx->fd = fd; + }else { + ictx =malloc (sizeof (*ictx)); +if (!ictx) +return ERR_PTR (-ENOMEM ); + ictx->fd =dup (fd); } ictx->ccfg = &erofs_ccfg[inode->z_algorithmtype[0 ]];
Signature · 1 line
2.43.5