]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: erofs - avoid undefined shift
authorMilan Broz <gmazyland@gmail.com>
Wed, 12 Oct 2022 21:02:27 +0000 (23:02 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Oct 2022 07:12:37 +0000 (09:12 +0200)
Erofs probe can use undefined shift if blkszbits
is a bogus value. Avoid this by limiting shift size.

Reproducer found with OSS-Fuzz (issue 52298) running over
cryptsetup project (blkid is used in header init).

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/erofs.c

index 559ce63c1482e0d9cfe318968e1b9262cca7c6cd..452bb8d3bd175d1cee862f3c39d8481702793925 100644 (file)
@@ -73,7 +73,7 @@ static int probe_erofs(blkid_probe pr, const struct blkid_idmag *mag)
                return errno ? -errno : BLKID_PROBE_NONE;
 
        /* EROFS is restricted to 4KiB block size */
-       if ((1U << sb->blkszbits) > 4096)
+       if (sb->blkszbits > 31 || (1U << sb->blkszbits) > 4096)
                return BLKID_PROBE_NONE;
 
        if (!erofs_verify_checksum(pr, mag, sb))