Re: [PATCH] Avoid disk sector_t overflow for >2TB ext3 filesystem
Andreas Dilger <[email protected]>
| Newsgroups | gmane.comp.file-systems.ext2.devel |
|---|---|
| Message-ID | <[email protected]> |
On May 22, 2006 11:24 -0700, Mingming Cao wrote: > 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. Patch > against 2.6.17-rc4. > > Signed-Off-By: Mingming Cao<[email protected]> > > > --- > > linux-2.6.16-ming/fs/ext3/resize.c | 9 +++++++++ > linux-2.6.16-ming/fs/ext3/super.c | 10 ++++++++++ > 2 files changed, 19 insertions(+) > > diff -puN fs/ext3/super.c~ext3_check_sector_t_overflow fs/ext3/super.c > --- linux-2.6.16/fs/ext3/super.c~ext3_check_sector_t_overflow 2006-05-19 17:19:43.000000000 -0700 > +++ linux-2.6.16-ming/fs/ext3/super.c 2006-05-22 10:54:27.000000000 -0700 > @@ -1579,6 +1579,16 @@ static int ext3_fill_super (struct super > 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); Minor - it's a bit easier to read the code if the "continuation" line is left-justified with the parenthesis instead of the tab on the next line. It would also be nice to print out the actual values involved: if (le32_to_cpu(es->s_blocks_count) > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { printk(KERN_ERR "EXT3-fs: filesystem on %s (%lu blocks) " "too large to mount safely\n", sb->s_id, le32_to_cpu(es->s_blocks_count)); > @@ -926,6 +926,15 @@ int ext3_group_extend(struct super_block > if (n_blocks_count == 0 || n_blocks_count == o_blocks_count) > return 0; > > + if (n_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); Minor - "too large to resize to %lu blocks safely\n", sb->s_id, n_blocks_count You can add an: Signed-Off-By: Andreas Dilger <[email protected]> Cheers, Andreas -- Andreas Dilger Principal Software Engineer Cluster File Systems, Inc. ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642