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

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