Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp28765imm; Fri, 21 Sep 2018 17:24:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV639sLwmFPdwpnP4W9L7zaGUOpYzqH4C5L32FLQW4HW3DH2SkP9mispvR/ju3YLJbEO6WVOi X-Received: by 2002:a63:26c4:: with SMTP id m187-v6mr133048pgm.268.1537575861936; Fri, 21 Sep 2018 17:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575861; cv=none; d=google.com; s=arc-20160816; b=ML+B+9yN//n9/8vpeWa3sJ2vGKp3wSmNXOlk4bQ0b6yHqai9CTDuy/T1kIIleBvwL5 jlx26E4KetA3BVNOjfWKnYhe9EdnNHwCa8mx4ADmU4H0Sj0b4dZEtS6+FBYMHWNPfPPT QOSCXrE083WptNrPb0D8n44ffI7ODFPncGYZqtHsFS7f2IdXkqGqV1Hcpgf/JUFdu3VM He4bVipsaxggJvmBhHnCgewman1LATzgXNLuSk/NTgGuIOvp29lRmUo1B5DbA18JWRck PhJz8quaMg1pQ/b3p3hlvSfFdyqqZHiCh+BACdI82CP8XwVeCHXSs9f/j78yJOMDdrm7 90xA== 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=jLXBX+N7p2JeHOeEek5dTJMgtMBVRIRYjz7VbINonys=; b=Zh/Enope+Ze8vPXt6wJ9khfCGDENf38ulE8+U8kms17Ncr6uAZwt+ntk6BvC0QZhd+ xjfHBGkZcwSFV+ylEBwXkUFNcgAEEhpf4fmzqlYamY4DCoCECaUp2ApRNfzY2J5+BQYy Dv2kczemI29Gla1B1K+0S58K65RAfPL4XQbzPON5R2uMjocdGuHmOhz3NkS+ZskcVquS O2pSNAnaN4vE/KnNaf0WQ0idCkNuWnTAQ+wHtnU1FfVIFgK/CfFNtrRGp/rmiux0rL9r dyXcN8s+i6GmjkqvT6IO7nHbRWvP4lsV15kLlsRu3a7EZc8Z5EURppq0pqDPPbcRUDsp f0gA== 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 k7-v6si26854870plt.327.2018.09.21.17.24.06; Fri, 21 Sep 2018 17:24:21 -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 S2392291AbeIVGNL (ORCPT + 99 others); Sat, 22 Sep 2018 02:13:11 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44250 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392012AbeIVGKs (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-0008BZ-6q; Sat, 22 Sep 2018 01:19:30 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdo-0000s6-3v; 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 30/63] ext4: fix false negatives *and* false positives in ext4_check_descriptors() 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 44de022c4382541cebdd6de4465d1f4f465ff1dd upstream. Ext4_check_descriptors() was getting called before s_gdb_count was initialized. So for file systems w/o the meta_bg feature, allocation bitmaps could overlap the block group descriptors and ext4 wouldn't notice. For file systems with the meta_bg feature enabled, there was a fencepost error which would cause the ext4_check_descriptors() to incorrectly believe that the block allocation bitmap overlaps with the block group descriptor blocks, and it would reject the mount. Fix both of these problems. Signed-off-by: Theodore Ts'o [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/ext4/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2086,7 +2086,7 @@ static int ext4_check_descriptors(struct struct ext4_sb_info *sbi = EXT4_SB(sb); ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); ext4_fsblk_t last_block; - ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0) + 1; + ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0); ext4_fsblk_t block_bitmap; ext4_fsblk_t inode_bitmap; ext4_fsblk_t inode_table; @@ -3987,6 +3987,7 @@ static int ext4_fill_super(struct super_ goto failed_mount2; } } + sbi->s_gdb_count = db_count; if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); goto failed_mount2; @@ -3999,7 +4000,6 @@ static int ext4_fill_super(struct super_ goto failed_mount2; } - sbi->s_gdb_count = db_count; get_random_bytes(&sbi->s_next_generation, sizeof(u32)); spin_lock_init(&sbi->s_next_gen_lock);