Blame SOURCES/e2fsprogs-1.42.9-libext2fs-buffer-overflow-closefs.patch

252946
commit 49d0fe2a14f2a23da2fe299643379b8c1d37df73
252946
Author: Theodore Ts'o <tytso@mit.edu>
252946
Date:   Fri Feb 6 12:46:39 2015 -0500
252946
252946
    libext2fs: fix potential buffer overflow in closefs()
252946
    
252946
    The bug fix in f66e6ce4446: "libext2fs: avoid buffer overflow if
252946
    s_first_meta_bg is too big" had a typo in the fix for
252946
    ext2fs_closefs().  In practice most of the security exposure was from
252946
    the openfs path, since this meant if there was a carefully crafted
252946
    file system, buffer overrun would be triggered when the file system was
252946
    opened.
252946
    
252946
    However, if corrupted file system didn't trip over some corruption
252946
    check, and then the file system was modified via tune2fs or debugfs,
252946
    such that the superblock was marked dirty and then written out via the
252946
    closefs() path, it's possible that the buffer overrun could be
252946
    triggered when the file system is closed.
252946
    
252946
    Also clear up a signed vs unsigned warning while we're at it.
252946
    
252946
    Thanks to Nick Kralevich <nnk@google.com> for asking me to look at
252946
    compiler warning in the code in question, which led me to notice the
252946
    bug in f66e6ce4446.
252946
    
252946
    Addresses: CVE-2015-1572
252946
    
252946
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
252946
252946
Index: e2fsprogs-1.42.9/lib/ext2fs/closefs.c
252946
===================================================================
252946
--- e2fsprogs-1.42.9.orig/lib/ext2fs/closefs.c
252946
+++ e2fsprogs-1.42.9/lib/ext2fs/closefs.c
252946
@@ -279,7 +279,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, 
252946
 	dgrp_t		j;
252946
 #endif
252946
 	char	*group_ptr;
252946
-	int	old_desc_blocks;
252946
+	blk64_t	old_desc_blocks;
252946
 	struct ext2fs_numeric_progress_struct progress;
252946
 
252946
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
252946
@@ -338,7 +338,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, 
252946
 	group_ptr = (char *) group_shadow;
252946
 	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) {
252946
 		old_desc_blocks = fs->super->s_first_meta_bg;
252946
-		if (old_desc_blocks > fs->super->s_first_meta_bg)
252946
+		if (old_desc_blocks > fs->desc_blocks)
252946
 			old_desc_blocks = fs->desc_blocks;
252946
 	} else
252946
 		old_desc_blocks = fs->desc_blocks;