1 Subject: Avoid disk sector_t overflow for >2TB ext3 filesystem
2 From: Mingming Cao <cmm@us.ibm.com>
5 If ext3 filesystem is larger than 2TB, and sector_t is a u32 (i.e.
6 CONFIG_LBD not defined in the kernel), the calculation of the disk sector
7 will overflow. Add check at ext3_fill_super() and ext3_group_extend() to
8 prevent mount/remount/resize >2TB ext3 filesystem if sector_t size is 4
11 Verified this patch on a 32 bit platform without CONFIG_LBD defined
12 (sector_t is 32 bits long), mount refuse to mount a 10TB ext3.
14 Signed-off-by: Mingming Cao<cmm@us.ibm.com>
15 Acked-by: Andreas Dilger <adilger@clusterfs.com>
16 Signed-off-by: Andrew Morton <akpm@osdl.org>
19 fs/ext3/resize.c | 10 ++++++++++
20 fs/ext3/super.c | 10 ++++++++++
21 2 files changed, 20 insertions(+)
23 diff -puN fs/ext3/super.c~avoid-disk-sector_t-overflow-for-2tb-ext3-filesystem fs/ext3/super.c
24 --- devel/fs/ext3/super.c~avoid-disk-sector_t-overflow-for-2tb-ext3-filesystem 2006-05-22 14:09:53.000000000 -0700
25 +++ devel-akpm/fs/ext3/super.c 2006-05-22 14:11:10.000000000 -0700
26 @@ -1565,6 +1565,17 @@ static int ext3_fill_super (struct super
30 + if (le32_to_cpu(es->s_blocks_count) >
31 + (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
32 + printk(KERN_ERR "EXT3-fs: filesystem on %s: "
33 + "too large to mount safely - %u blocks\n", sb->s_id,
34 + le32_to_cpu(es->s_blocks_count));
35 + if (sizeof(sector_t) < 8)
37 + "EXT3-fs: CONFIG_LBD not enabled\n");
41 sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) -
42 le32_to_cpu(es->s_first_data_block) +
43 EXT3_BLOCKS_PER_GROUP(sb) - 1) /