]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: erofs: validate blkszbits before checksum calculation
authorKarel Zak <kzak@redhat.com>
Wed, 15 Apr 2026 18:40:03 +0000 (20:40 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Apr 2026 12:07:45 +0000 (14:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/erofs.c

index 57fd80220daa2a1ab780347e7fb2daf66a455f15..dd3022654ec903d5110ea368bb2d8578dd045379 100644 (file)
@@ -52,6 +52,13 @@ static int erofs_verify_checksum(blkid_probe pr, const struct blkid_idmag *mag,
                return 1;
 
        expected = le32_to_cpu(sb->checksum);
+
+       /* kernel validates blkszbits 9..PAGE_SHIFT;
+        * block size must be > EROFS_SUPER_OFFSET to avoid underflow */
+       if (sb->blkszbits < 9 || sb->blkszbits > 16
+           || (1U << sb->blkszbits) <= EROFS_SUPER_OFFSET)
+               return 0;
+
        csummed_size = (1U << sb->blkszbits) - EROFS_SUPER_OFFSET;
 
        csummed = blkid_probe_get_sb_buffer(pr, mag, csummed_size);