diff options
author | Jan Kara <jack@suse.cz> | 2012-07-10 17:58:04 +0200 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2013-01-16 16:45:06 -0500 |
commit | 1bf86851f449172c5cb6ed1d8a05c5e45994b56b (patch) | |
tree | fb65a177291507d54ce665260b1070f68565c2c5 | |
parent | d7542a6eb171336db2101522803f46e6e624bd1f (diff) |
udf: Improve table length check to avoid possible overflow
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.
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r-- | fs/udf/super.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 988a332e30d..1d36fdd4ae5 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1307,7 +1307,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, BUG_ON(ident != TAG_IDENT_LVD); 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, "error loading logical volume descriptor: " "Partition table too long (%u > %lu)\n", table_len, sb->s_blocksize - sizeof(*lvd)); |