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

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