[PATCH 1/2] erofs-utils: refuse block sizes larger than EROFS_MAX_BLOCK_SIZE

Gao Xiang hsiangkao at linux.alibaba.com
Sat Jun 3 23:31:29 AEST 2023


The maximum supported block size is EROFS_MAX_BLOCK_SIZE.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/super.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/super.c b/lib/super.c
index 17f849e..5f70686 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -88,15 +88,14 @@ int erofs_read_superblock(void)
 	sbi.feature_compat = le32_to_cpu(dsb->feature_compat);
 
 	sbi.blkszbits = dsb->blkszbits;
-	/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
-	if (sbi.blkszbits < 9) {
+	if (sbi.blkszbits < 9 ||
+	    (1 << sbi.blkszbits) > EROFS_MAX_BLOCK_SIZE) {
 		erofs_err("blksize %d isn't supported on this platform",
 			  erofs_blksiz());
 		return ret;
-	}
-
-	if (!check_layout_compatibility(&sbi, dsb))
+	} else if (!check_layout_compatibility(&sbi, dsb)) {
 		return ret;
+	}
 
 	sbi.primarydevice_blocks = le32_to_cpu(dsb->blocks);
 	sbi.meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
-- 
2.24.4



More information about the Linux-erofs mailing list