From: Milan Broz Date: Thu, 13 Oct 2022 12:59:15 +0000 (+0200) Subject: libblkid: ext - avoid undefined shift X-Git-Tag: v2.39-rc1~486 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=90eacdebd0d7d9ce0ff15317f2e10900b0aad4b3;p=thirdparty%2Futil-linux.git libblkid: ext - avoid undefined shift Ext filesystems probe can use undefined shift if s_log_block_size is a bogus value. Avoid this by limiting shift size. Reproducer found with OSS-Fuzz (issue 52370) running over cryptsetup project (blkid is used in header init). Signed-off-by: Karel Zak --- diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c index e6d620167a..1c799429e5 100644 --- a/libblkid/src/superblocks/ext.c +++ b/libblkid/src/superblocks/ext.c @@ -189,8 +189,9 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es) le32_to_cpu(es->s_rev_level), le16_to_cpu(es->s_minor_rev_level)); - uint32_t block_size = 1024U << le32_to_cpu(es->s_log_block_size); + uint32_t block_size = 0; if (le32_to_cpu(es->s_log_block_size) < 32){ + block_size = 1024U << le32_to_cpu(es->s_log_block_size); blkid_probe_set_fsblocksize(pr, block_size); blkid_probe_set_block_size(pr, block_size); }