diff mbox

[3/6] e2fsck: Fix incorrect bbitmap checksum failure caused by integer overflow

Message ID 20130829004404.3190.22438.stgit@blackbox.djwong.org
State Accepted, archived
Headers show

Commit Message

Darrick Wong Aug. 29, 2013, 12:44 a.m. UTC
On a filesystem with more than 2^32 blocks, the block group checksum test will
fail because "i" (the group number) is a 32-bit quantity that is used to
calculate the group's block bitmap block number.  Unfortunately, "i" is not
automatically promoted to 64-bit for this calculation and overflows.  When this
happens, e2fsck will incorrectly report bitmap checksum errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 e2fsck/pass5.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Theodore Ts'o Sept. 16, 2013, 1:42 p.m. UTC | #1
On Wed, Aug 28, 2013 at 05:44:04PM -0700, Darrick J. Wong wrote:
> On a filesystem with more than 2^32 blocks, the block group checksum test will
> fail because "i" (the group number) is a 32-bit quantity that is used to
> calculate the group's block bitmap block number.  Unfortunately, "i" is not
> automatically promoted to 64-bit for this calculation and overflows.  When this
> happens, e2fsck will incorrectly report bitmap checksum errors.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied to the next branch, thanks.

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index 51e4683..0fe7045 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -168,7 +168,7 @@  static void check_block_bitmap_checksum(e2fsck_t ctx)
 
 		blk_itr = EXT2FS_B2C(ctx->fs,
 				     ctx->fs->super->s_first_data_block) +
-			  (i * (nbytes << 3));
+			  ((blk64_t)i * (nbytes << 3));
 		retval = ext2fs_get_block_bitmap_range2(ctx->fs->block_map,
 							blk_itr, nbytes << 3,
 							buf);