Whamcloud - gitweb
Modified ChangeLog entry.
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-sector_t-overflow-2.4.patch
1 Subject: Avoid disk sector_t overflow for >2TB ext3 filesystem
2 From: Mingming Cao <cmm@us.ibm.com>
3
4
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
9 bytes.
10
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.
13
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>
17 ---
18
19  fs/ext3/resize.c |   10 ++++++++++
20  fs/ext3/super.c  |   10 ++++++++++
21  2 files changed, 20 insertions(+)
22
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,14 @@ static int ext3_fill_super (struct super
27                 goto failed_mount;
28         }
29  
30 +       if (le32_to_cpu(es->s_blocks_count) >
31 +           (unsigned long)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
32 +               printk(KERN_ERR "EXT3-fs: filesystem on %s: "
33 +                      "too large to mount safely - %u blocks\n",
34 +                      bdevname(sb->s_dev), le32_to_cpu(es->s_blocks_count));
35 +               goto failed_mount;
36 +       }
37 +
38         sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) -
39                                le32_to_cpu(es->s_first_data_block) +
40                                EXT3_BLOCKS_PER_GROUP(sb) - 1) /
41 _