aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/resize.c
diff options
context:
space:
mode:
authorMingming Cao <cmm@us.ibm.com>2006-06-25 08:47:50 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:07 -0400
commitfcd5df35882b128ef3e160fab3074e6fe7ae501b (patch)
tree2ffa30054f510e0fdca988d18ab28d6df12c3f06 /fs/ext3/resize.c
parentb61367732fc273977cc3fb85c272ce1a7bb1f533 (diff)
[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 'fs/ext3/resize.c')
-rw-r--r--fs/ext3/resize.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 34b39e9a1e5a..a31dff81ed77 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -925,6 +925,16 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
925 if (n_blocks_count == 0 || n_blocks_count == o_blocks_count) 925 if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
926 return 0; 926 return 0;
927 927
928 if (n_blocks_count > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
929 printk(KERN_ERR "EXT3-fs: filesystem on %s:"
930 " too large to resize to %lu blocks safely\n",
931 sb->s_id, n_blocks_count);
932 if (sizeof(sector_t) < 8)
933 ext3_warning(sb, __FUNCTION__,
934 "CONFIG_LBD not enabled\n");
935 return -EINVAL;
936 }
937
928 if (n_blocks_count < o_blocks_count) { 938 if (n_blocks_count < o_blocks_count) {
929 ext3_warning(sb, __FUNCTION__, 939 ext3_warning(sb, __FUNCTION__,
930 "can't shrink FS - resize aborted"); 940 "can't shrink FS - resize aborted");