stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "ext4: add sanity checking to count_overhead()" has been added to the 4.9-stable tree
@ 2017-01-04 10:07 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-01-04 10:07 UTC (permalink / raw)
  To: tytso, gregkh; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    ext4: add sanity checking to count_overhead()

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ext4-add-sanity-checking-to-count_overhead.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From c48ae41bafe31e9a66d8be2ced4e42a6b57fa814 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Fri, 18 Nov 2016 13:37:47 -0500
Subject: ext4: add sanity checking to count_overhead()

From: Theodore Ts'o <tytso@mit.edu>

commit c48ae41bafe31e9a66d8be2ced4e42a6b57fa814 upstream.

The commit "ext4: sanity check the block and cluster size at mount
time" should prevent any problems, but in case the superblock is
modified while the file system is mounted, add an extra safety check
to make sure we won't overrun the allocated buffer.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/super.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3193,10 +3193,15 @@ static int count_overhead(struct super_b
 			ext4_set_bit(s++, buf);
 			count++;
 		}
-		for (j = ext4_bg_num_gdb(sb, grp); j > 0; j--) {
-			ext4_set_bit(EXT4_B2C(sbi, s++), buf);
-			count++;
+		j = ext4_bg_num_gdb(sb, grp);
+		if (s + j > EXT4_BLOCKS_PER_GROUP(sb)) {
+			ext4_error(sb, "Invalid number of block group "
+				   "descriptor blocks: %d", j);
+			j = EXT4_BLOCKS_PER_GROUP(sb) - s;
 		}
+		count += j;
+		for (; j > 0; j--)
+			ext4_set_bit(EXT4_B2C(sbi, s++), buf);
 	}
 	if (!count)
 		return 0;


Patches currently in stable-queue which might be from tytso@mit.edu are

queue-4.9/ext4-reject-inodes-with-negative-size.patch
queue-4.9/ext4-fix-in-superblock-mount-options-processing.patch
queue-4.9/ext4-don-t-lock-buffer-in-ext4_commit_super-if-holding-spinlock.patch
queue-4.9/ext4-fix-mballoc-breakage-with-64k-block-size.patch
queue-4.9/ext4-do-not-perform-data-journaling-when-data-is-encrypted.patch
queue-4.9/ext4-use-more-strict-checks-for-inodes_per_block-on-mount.patch
queue-4.9/ext4-add-sanity-checking-to-count_overhead.patch
queue-4.9/ext4-return-enomem-instead-of-success.patch
queue-4.9/ext4-fix-stack-memory-corruption-with-64k-block-size.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-04 10:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-04 10:07 Patch "ext4: add sanity checking to count_overhead()" has been added to the 4.9-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).