Subject: Avoid disk sector_t overflow for >2TB ext3 filesystem From: Mingming Cao 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 Acked-by: Andreas Dilger Signed-off-by: Andrew Morton --- fs/ext3/resize.c | 10 ++++++++++ fs/ext3/super.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff -puN fs/ext3/super.c~avoid-disk-sector_t-overflow-for-2tb-ext3-filesystem fs/ext3/super.c --- devel/fs/ext3/super.c~avoid-disk-sector_t-overflow-for-2tb-ext3-filesystem 2006-05-22 14:09:53.000000000 -0700 +++ devel-akpm/fs/ext3/super.c 2006-05-22 14:11:10.000000000 -0700 @@ -1565,6 +1565,14 @@ static int ext3_fill_super (struct super goto failed_mount; } + if (le32_to_cpu(es->s_blocks_count) > + (unsigned long)(~0ULL) >> (sb->s_blocksize_bits - 9)) { + printk(KERN_ERR "EXT3-fs: filesystem on %s: " + "too large to mount safely - %u blocks\n", + bdevname(sb->s_dev), le32_to_cpu(es->s_blocks_count)); + goto failed_mount; + } + sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - le32_to_cpu(es->s_first_data_block) + EXT3_BLOCKS_PER_GROUP(sb) - 1) / _