[PATCH] erofs-utils: fsck: fix an infinite loop of big pclusters

Gao Xiang xiang at kernel.org
Fri May 12 00:15:20 AEST 2023


From: Gao Xiang <hsiangkao at linux.alibaba.com>

Actually it's outdated code compared with kernel
commit b86269f43892 ("erofs: support parsing big pcluster compact indexes")

This will cause fsck.erofs works endlessly on some crafted images.

Reported-by: Chaoming Yang <lometsj at live.com>
Fixes: 418fb683fd96 ("erofs-utils: fsck: fix an infinite loop of big pcluster")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/zmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/zmap.c b/lib/zmap.c
index 7b0fd83..6d9b033 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -322,7 +322,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
 					nblk += lo & ~Z_EROFS_VLE_DI_D0_CBLKCNT;
 					continue;
 				}
-				if (lo == 1) {
+				if (lo <= 1) {
 					DBG_BUGON(1);
 					/* --i; ++nblk;	continue; */
 					return -EFSCORRUPTED;
-- 
2.30.2



More information about the Linux-erofs mailing list