linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] resize2fs: fix 32-bit overflow issue which can corrupt 64-bit file systems
@ 2013-01-03 14:13 Theodore Ts'o
  2013-01-03 14:13 ` [PATCH 2/4] resize2fs: fix 32-bit overflow when calculating the number of free blocks Theodore Ts'o
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Theodore Ts'o @ 2013-01-03 14:13 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Fix a 32-bit overflow bug caused by a missing blk64_t cast which can
cause the block bitmap to get corrupted when doing an off-line resize
of a 64-bit file system.

This problem can be reproduced as follows:

rm -f foo.img; touch foo.img
truncate -s 8T foo.img
mke2fs -F -t ext4 -O 64bit foo.img
e2fsck -f foo.img
truncate -s 21T foo.img
resize2fs foo.img
e2fsck -fy foo.img

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/resize2fs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 092cfbd..0407e41 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -197,8 +197,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
 		if (!(ext2fs_bg_flags_test(fs, g, EXT2_BG_BLOCK_UNINIT)))
 			continue;
 
-		blk = (g * fs->super->s_blocks_per_group) +
-			fs->super->s_first_data_block;
+		blk = ext2fs_group_first_block2(fs, g);
 
 		ext2fs_super_and_bgd_loc2(fs, g, &super_blk,
 					  &old_desc_blk, &new_desc_blk, 0);
@@ -846,8 +845,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
 			 * The block bitmap is uninitialized, so skip
 			 * to the next block group.
 			 */
-			blk = ((g+1) * fs->super->s_blocks_per_group) +
-				fs->super->s_first_data_block - 1;
+			blk = ext2fs_group_first_block2(fs, g+1) - 1;
 			continue;
 		}
 		if (ext2fs_test_block_bitmap2(old_fs->block_map, blk) &&
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-04 17:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-03 14:13 [PATCH 1/4] resize2fs: fix 32-bit overflow issue which can corrupt 64-bit file systems Theodore Ts'o
2013-01-03 14:13 ` [PATCH 2/4] resize2fs: fix 32-bit overflow when calculating the number of free blocks Theodore Ts'o
2013-01-03 14:13 ` [PATCH 3/4] resize2fs: add resource tracking as a debug option Theodore Ts'o
2013-01-03 14:13 ` [PATCH 4/4] resize2fs: use [un]mark_block_range bitmap functions to reduce CPU usage Theodore Ts'o
2013-01-03 15:56 ` [PATCH 1/4] resize2fs: fix 32-bit overflow issue which can corrupt 64-bit file systems Eric Sandeen
2013-01-03 17:16   ` Theodore Ts'o
2013-01-03 18:57   ` [PATCH] Fix 32-bit overflow problems: dgrp_t * s_blocks_per_group Theodore Ts'o
2013-01-04 17:21     ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).