Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2010198imm; Tue, 10 Jul 2018 11:32:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeRcLdSfRNDeYxIUzoZ5wFHZsNTSDE5+tw2wCRnWenAy4VU91ZuK33T6DC+80NxLBbLPOze X-Received: by 2002:aa7:82d9:: with SMTP id f25-v6mr26652285pfn.218.1531247543343; Tue, 10 Jul 2018 11:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247543; cv=none; d=google.com; s=arc-20160816; b=Rs0/yqbV7P+0JVJ0YDqKfbPBB28YUT2WKpwW0bjhyYCCx2hICfLw2YBlXEHYntCbRO HP4XlWJHn1VXv30JzpynK53yseLiKp5j0Ave+dQr4vPO1HBHt5IraiQbrplcHDhn2ndw hOBMb/R9qxYIlMAd9YrqzTcG8cu65mP0fhInEji0QZRbUsVgQkPx3/R6/UrNI/HehEld a5CAOT+j3MCimc6FbULA97XFzxpvQ5arf/oG80OHWOBwyMV9913u7EgUSP97i4xJELht BC46Cel1nQ84VFXK0lXtlCeusDGoJsjQbQ4YgbZLGqxtmVbPQXryaMsmr0Kj/kH4RYdV 1nRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=z5UZaWESCbVhjGZW5ckWJUfnwLGQo19P5sZQIr/kZbg=; b=A7jKGowRTt1BoFz1vtesQxixMPxzsLupNruicEaXF/qBD7LXhuzQSd01hoF5KKR3Ff YErxnwGiGriM/yl9ulP2lVjCjZFuHNk76UxpkSlKBrrMkhZVVr9i10TF/lfXFewxiqRD 9hzW3m1GEiN0P5JbkyhZH4eXAOegzuKzMUWfSsxR7pkp3DiknJRrPs7WfaAVPFpPAJkI 1SrpUr+HARsdQ+pNlp1rxobhK76AqHyahV5o0C1JHlMbX4WD/B1PpMASzunyXz96muBY 3J3cUjEpQylbf0gQZfOjlsrkZ02dqDBGXMLRFI9ukCIwLFjuJR5g8c+ilRAY5Z+noXTT qERA== 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 v71-v6si18352714pfj.354.2018.07.10.11.32.08; Tue, 10 Jul 2018 11:32:23 -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 S2388024AbeGJSaW (ORCPT + 99 others); Tue, 10 Jul 2018 14:30:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45550 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733298AbeGJSaW (ORCPT ); Tue, 10 Jul 2018 14:30:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 55E58EC2; Tue, 10 Jul 2018 18:30:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , stable@kernel.org Subject: [PATCH 4.9 28/52] ext4: always check block group bounds in ext4_init_block_bitmap() Date: Tue, 10 Jul 2018 20:24:56 +0200 Message-Id: <20180710182452.049039704@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable 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 Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/balloc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -183,7 +183,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)); @@ -216,22 +215,19 @@ static int ext4_init_block_bitmap(struct start = ext4_group_first_block_no(sb, block_group); - if (ext4_has_feature_flex_bg(sb)) - 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); }