stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Hackmann <ghackmann@android.com>
To: stable@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>,
	Ben Hutchings <ben@decadent.org.uk>,
	Greg Hackmann <ghackmann@google.com>
Subject: [PATCH 3.18.y 03/10] ext4: always check block group bounds in ext4_init_block_bitmap()
Date: Thu,  4 Oct 2018 10:53:13 -0700	[thread overview]
Message-ID: <20181004175320.181881-4-ghackmann@google.com> (raw)
In-Reply-To: <20181004175320.181881-1-ghackmann@google.com>

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

commit 819b23f1c501b17b9694325471789e6b5cc2d0d2 upstream.

Regardless of whether the flex_bg feature is set, we should always
check to make sure the bits we are setting in the block bitmap are
within the block group bounds.

https://bugzilla.kernel.org/show_bug.cgi?id=199865

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
---
 fs/ext4/balloc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 7b7691353cf3..c56b9b4f6f76 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -184,7 +184,6 @@ static int ext4_init_block_bitmap(struct super_block *sb,
 	unsigned int bit, bit_max;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	ext4_fsblk_t start, tmp;
-	int flex_bg = 0;
 	struct ext4_group_info *grp;
 
 	J_ASSERT_BH(bh, buffer_locked(bh));
@@ -217,22 +216,19 @@ static int ext4_init_block_bitmap(struct super_block *sb,
 
 	start = ext4_group_first_block_no(sb, block_group);
 
-	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
-		flex_bg = 1;
-
 	/* Set bits for block and inode bitmaps, and inode table */
 	tmp = ext4_block_bitmap(sb, gdp);
-	if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
+	if (ext4_block_in_group(sb, tmp, block_group))
 		ext4_set_bit(EXT4_B2C(sbi, tmp - start), bh->b_data);
 
 	tmp = ext4_inode_bitmap(sb, gdp);
-	if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
+	if (ext4_block_in_group(sb, tmp, block_group))
 		ext4_set_bit(EXT4_B2C(sbi, tmp - start), bh->b_data);
 
 	tmp = ext4_inode_table(sb, gdp);
 	for (; tmp < ext4_inode_table(sb, gdp) +
 		     sbi->s_itb_per_group; tmp++) {
-		if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
+		if (ext4_block_in_group(sb, tmp, block_group))
 			ext4_set_bit(EXT4_B2C(sbi, tmp - start), bh->b_data);
 	}
 
-- 
2.19.0.605.g01d371f741-goog

  parent reply	other threads:[~2018-10-05  0:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 17:53 [PATCH 3.18.y 00/10] recent ext4 CVE fixes Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 01/10] ext4: only look at the bg_flags field if it is valid Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 02/10] ext4: fix check to prevent initializing reserved inodes Greg Hackmann
2018-10-04 17:53 ` Greg Hackmann [this message]
2018-10-04 17:53 ` [PATCH 3.18.y 04/10] ext4: fix false negatives *and* false positives in ext4_check_descriptors() Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 05/10] ext4: add corruption check in ext4_xattr_set_entry() Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 06/10] ext4: always verify the magic number in xattr blocks Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 07/10] ext4: never move the system.data xattr out of the inode body Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 08/10] ext4: add more inode number paranoia checks Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 09/10] jbd2: don't mark block as modified if the handle is out of credits Greg Hackmann
2018-10-04 17:53 ` [PATCH 3.18.y 10/10] ext4: avoid running out of journal credits when appending to an inline file Greg Hackmann
2018-10-11  9:17 ` [PATCH 3.18.y 00/10] recent ext4 CVE fixes Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181004175320.181881-4-ghackmann@google.com \
    --to=ghackmann@android.com \
    --cc=ben@decadent.org.uk \
    --cc=ghackmann@google.com \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).