summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-07-10 17:58:04 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-09 08:22:53 -0700
commitee0fcc97c489f4fe29a66f1615ca3fb1513c4c99 (patch)
tree5a4e9a89a083f26f1fc0696f3f75ceff965b309b /fs
parent06fac439bbc3549d5402fb736895a76e3b668a38 (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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/super.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 8d86a8706c0e..e660ffdd91b6 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1283,7 +1283,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_err(sb, "error loading logical volume descriptor: "
"Partition table too long (%u > %lu)\n", table_len,
sb->s_blocksize - sizeof(*lvd));