From f217849ff671739b737a84694d346616eb0ed669 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 22 Sep 2021 17:51:41 +0800 Subject: [PATCH 1/2] erofs: fix misbehavior of unsupported chunk format check ANBZ: #6079 commit d705117ddd724a9d4877e338e4587010ab6a1c62 upstream. Unsupported chunk format should be checked with "if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)" Found when checking with 4k-byte blockmap (although currently mkfs uses inode chunk indexes format by default.) Link: https://lore.kernel.org/r/20210922095141.233938-1-hsiangkao@linux.alibaba.com Fixes: c5aa903a59db ("erofs: support reading chunk-based uncompressed files") Reviewed-by: Liu Bo Reviewed-by: Chao Yu Signed-off-by: Gao Xiang --- fs/erofs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index d8df9834a0db..b3968ced2549 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -177,7 +177,7 @@ static void *erofs_read_inode(struct erofs_buf *buf, } if (vi->datalayout == EROFS_INODE_CHUNK_BASED) { - if (!(vi->chunkformat & EROFS_CHUNK_FORMAT_ALL)) { + if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) { erofs_err(inode->i_sb, "unsupported chunk format %x of nid %llu", vi->chunkformat, vi->nid); -- Gitee From 96abb3c39a76f610b473b11efdb22d1db02203dd Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 2 Aug 2023 23:16:24 +0800 Subject: [PATCH 2/2] anolis: erofs: fix EROFS completely broken due to RAFS v6 support ANBZ: #6079 Any erofs will crash the kernel when using block interface to mount: [exception RIP: __erofs_bread+89] RIP: ffffffffc0735dd9 RSP: ffffba1240f9bd60 RFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000000000000c RDX: ffff9a7f40480ed8 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffba1240f9bda8 R8: 0000000000000001 R9: ffffba1240f9bda8 R10: ffff9a7f40480ed8 R11: ffffba1240f9bde0 R12: ffff9a7f40481050 R13: 0000000000000001 R14: ffff9a7f40480ed8 R15: 0000000000000000 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #5 [ffffba1240f9bd98] erofs_read_superblock at ffffffffc073424e [erofs] #6 [ffffba1240f9be38] erofs_fc_fill_super at ffffffffc073451a [erofs] #7 [ffffba1240f9be60] get_tree_bdev at ffffffff8c39086f #8 [ffffba1240f9bea0] vfs_get_tree at ffffffff8c38f245 #9 [ffffba1240f9bec0] do_new_mount at ffffffff8c3b69a6 Fixes: 37bc6e053254 ("anolis: erofs: support passing in struct file * for FUSE") Signed-off-by: Gao Xiang --- fs/erofs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index cf1f56ac04fd..777de4ae3dd7 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -56,7 +56,7 @@ void *__erofs_bread(struct super_block *sb, struct erofs_buf *buf, if (!page || page->index != index) { erofs_put_metabuf(buf); - if (EROFS_SB(sb)->bootstrap) { + if (sb && EROFS_SB(sb)->bootstrap) { unsigned int nofs_flag; nofs_flag = memalloc_nofs_save(); -- Gitee