diff options
author | Mingming Cao <cmm@us.ibm.com> | 2006-06-25 14:47:50 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 19:01:07 +0200 |
commit | fcd5df35882b128ef3e160fab3074e6fe7ae501b (patch) | |
tree | 2ffa30054f510e0fdca988d18ab28d6df12c3f06 /fs/ext3/super.c | |
parent | [PATCH] schedule_on_each_cpu(): reduce kmalloc() size (diff) | |
download | linux-fcd5df35882b128ef3e160fab3074e6fe7ae501b.tar.xz linux-fcd5df35882b128ef3e160fab3074e6fe7ae501b.zip |
[PATCH] Avoid disk sector_t overflow for >2TB ext3 filesystem
If ext3 filesystem is larger than 2TB, and sector_t is a u32 (i.e.
CONFIG_LBD not defined in the kernel), the calculation of the disk sector
will overflow. Add check at ext3_fill_super() and ext3_group_extend() to
prevent mount/remount/resize >2TB ext3 filesystem if sector_t size is 4
bytes.
Verified this patch on a 32 bit platform without CONFIG_LBD defined
(sector_t is 32 bits long), mount refuse to mount a 10TB ext3.
Signed-off-by: Mingming Cao<cmm@us.ibm.com>
Acked-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to '')
-rw-r--r-- | fs/ext3/super.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index a60cc6ec130f..df98a7709252 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1565,6 +1565,16 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) goto failed_mount; } + if (le32_to_cpu(es->s_blocks_count) > + (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { + printk(KERN_ERR "EXT3-fs: filesystem on %s:" + " too large to mount safely\n", sb->s_id); + if (sizeof(sector_t) < 8) + printk(KERN_WARNING "EXT3-fs: CONFIG_LBD not " + "enabled\n"); + goto failed_mount; + } + if (EXT3_BLOCKS_PER_GROUP(sb) == 0) goto cantfind_ext3; sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - |