Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp28046imm; Fri, 21 Sep 2018 17:23:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV62/epCBCNPFunL9yCKcsMJkkDtfhwsIP8SYNyZxVTMbmwr4hlCG95b2Hy8VgOj+95i9rEbc X-Received: by 2002:a17:902:988a:: with SMTP id s10-v6mr119838plp.200.1537575787128; Fri, 21 Sep 2018 17:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575787; cv=none; d=google.com; s=arc-20160816; b=Y/hb6F4sqguCyhdLc4kJIi5Pm36tUQxrSsm/BwdbMuhVAMqyW186cknoMtwafULjb3 6WMJF6NCq2SrXNAsbaragSIji9bg3W1yDPKgbB7Yaxcnks20Yea0MuaLc3fKvXe0iGTu S63mutN8QJOqnrsZeUFRApfUgxGg9q01aR5Or2MS42qsHENSvMsWmhSS4c3uf3cgMVSp hdZAKx3Mvk2yRwqfvUUfHUCIJTgljfiBKyaKrtg9rwfppJuQigj8GGpBs2BsydyKU52O JQ4OPvgbxnkVJCZpC29GBoITGd3d+v8R48BaT46lXFs2hxsUX4DxFrSrI5wWPYu2NbOH dBHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=Z4LKDU91ihfu2A6HiEYnpJaYBA1HOmpE3rHXMLwxxWM=; b=HW+2zc99432/HQwPHWiZdGkNcfLYCtXHKjwdwlSuccLB0wqvxyLJPlNS3WjK9jgDHf BvMEAw34lfcvv837hB/iDUnmvB9lxmjpCcqVJV3OxA0SicnUyIT7FsRNIu0WgQv8HkC2 foqMaTOH96pw5Pk0ro8HDv0pG2yFABxgw1yOKCHaZLDiQ/hoNcjE8QOTJuU6SyUCQbEO aVVHoa4ZJlxruzAaSe4F0KxLWYK3YH3LHB27Y9uQNqzr44QY1KU/iVg4B1KWfQS5uZnC LOaksVW6HLwNfRawpFNILRNsJCRLKlVpApjH5wLlqm2vM7WKXjCbt2H6G6QlG5n25sdF GZhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si27634002plv.28.2018.09.21.17.22.51; Fri, 21 Sep 2018 17:23:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392304AbeIVGNL (ORCPT + 99 others); Sat, 22 Sep 2018 02:13:11 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44241 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392011AbeIVGKs (ORCPT ); Sat, 22 Sep 2018 02:10:48 -0400 Received: from [2a02:8011:400e:2:cbab:f00:c93f:614] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1g3Vdy-0008BY-5F; Sat, 22 Sep 2018 01:19:30 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdo-0000rr-0B; Sat, 22 Sep 2018 01:19:20 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Theodore Ts'o" Date: Sat, 22 Sep 2018 01:15:42 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 27/63] ext4: always check block group bounds in ext4_init_block_bitmap() In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:cbab:f00:c93f:614 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.58-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/ext4/balloc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -184,7 +184,6 @@ static int ext4_init_block_bitmap(struct 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 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); }