Commit 6b804000 authored by Jan Kara's avatar Jan Kara Committed by Willy Tarreau

udf: Improve table length check to avoid possible overflow

commit 57b9655d 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: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 65ff664e
......@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment