Skip to contentSkip to conversation

erofs: fix shift-out-of-bounds of blkszbits

PATCH In review Gao Xiang 3 participants 3 messages Jan 20, 2021 – Feb 11, 2021 1 message not in the archive EROFS file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Gao Xiang

author
#1 lore raw

PATCH 1/1 erofs: fix shift-out-of-bounds of blkszbits

From: Gao Xiang <[email protected]>

syzbot generated a crafted bitszbits which can be shifted out-of-bounds[1]. So directly print unsupported blkszbits instead of blksize.

[1] https://lore.kernel.org/r/[email protected]

---
 fs/erofs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/erofs/super.c +2 -2
index be10b16ea66e..d5a6b9b888a5 100644
@@ -158,8 +158,8 @@ static int erofs_read_superblock(struct super_block *sb)
 	blkszbits = dsb->blkszbits;
 	/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
 	if (blkszbits != LOG_BLOCK_SIZE) {
-		erofs_err(sb, "blksize %u isn't supported on this platform",
-			  1 << blkszbits);
+		erofs_err(sb, "blkszbits %u isn't supported on this platform",
+			  blkszbits);
 		goto out;
 	}
 
Signature · 1 line
2.24.0
#2 lore raw

Hi Chao,

Quoted 9 lines · Gao Xiang

From: Gao Xiang <[email protected]>

syzbot generated a crafted bitszbits which can be shifted out-of-bounds[1]. So directly print unsupported blkszbits instead of blksize.

[1] https://lore.kernel.org/r/[email protected]

Could you kindly review this trivial syzaller patch as well? Since "erofs: initialized fields can only be observed after bit is set" is somewhat serious on some weak-memory-order designed platforms (no idea why our hisilison ARM64 platform didn't observe it before.) I intended to prepare this for 5.13 cycle directly with ongoing multi pcluster / LZMA in-kernel decompresion. But that regression seems a bit important to upstream for the next 5.12 cycle....

Thanks,
Gao Xiang

Quoted 22 lines
---
 fs/erofs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/erofs/super.c +2 -2
index be10b16ea66e..d5a6b9b888a5 100644
@@ -158,8 +158,8 @@ static int erofs_read_superblock(struct super_block *sb)
 	blkszbits = dsb->blkszbits;
 	/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
 	if (blkszbits != LOG_BLOCK_SIZE) {
-		erofs_err(sb, "blksize %u isn't supported on this platform",
-			  1 << blkszbits);
+		erofs_err(sb, "blkszbits %u isn't supported on this platform",
+			  blkszbits);
 		goto out;
 	}
 
Signature · 1 line
2.24.0
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Gao Xiang
Quoted 9 lines · Gao Xiang via Linux-erofs

From: Gao Xiang <[email protected]>

syzbot generated a crafted bitszbits which can be shifted out-of-bounds[1]. So directly print unsupported blkszbits instead of blksize.

[1] https://lore.kernel.org/r/[email protected]

Sorry, I missed this patch.

Thanks,