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

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