]> git.hungrycats.org Git - linux/commitdiff
udf: Improve table length check to avoid possible overflow
authorJan Kara <jack@suse.cz>
Tue, 10 Jul 2012 15:58:04 +0000 (17:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Oct 2012 21:37:55 +0000 (23:37 +0200)
commit 57b9655d01ef057a523e810d29c37ac09b80eead upstream.

When a partition table length is corrupted to be close to 1 << 32, the
check for its length may overflow on 32-bit systems and we will think
the length is valid. Later on the kernel can crash trying to read beyond
end of buffer. Fix the check to avoid possible overflow.

CC: stable@vger.kernel.org
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Willy Tarreau <w@1wt.eu>
fs/udf/super.c

index 0388d43f72002e259dc3beb39b6bc5bd6477f921..6e5e5a96fc6fdeafa8c65c508b0029955dfaeee5 100644 (file)
@@ -1259,7 +1259,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
        lvd = (struct logicalVolDesc *)bh->b_data;
 
        table_len = le32_to_cpu(lvd->mapTableLength);
-       if (sizeof(*lvd) + table_len > sb->s_blocksize) {
+       if (table_len > sb->s_blocksize - sizeof(*lvd)) {
                udf_error(sb, __func__, "error loading logical volume descriptor: "
                          "Partition table too long (%u > %lu)\n", table_len,
                          sb->s_blocksize - sizeof(*lvd));