From patchwork Fri Aug 1 18:11:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 375827 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 692451400E7 for ; Sat, 2 Aug 2014 04:11:59 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755155AbaHASL6 (ORCPT ); Fri, 1 Aug 2014 14:11:58 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:32887 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706AbaHASL6 (ORCPT ); Fri, 1 Aug 2014 14:11:58 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s71IBuGR020378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Aug 2014 18:11:57 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s71IBtgk027924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 1 Aug 2014 18:11:56 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s71IBtUe000423; Fri, 1 Aug 2014 18:11:55 GMT Received: from localhost (/24.21.154.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Aug 2014 11:11:54 -0700 Subject: [PATCH 02/19] e2fsck: never free critical metadata blocks in the block found map From: "Darrick J. Wong" To: tytso@mit.edu, darrick.wong@oracle.com Cc: linux-ext4@vger.kernel.org Date: Fri, 01 Aug 2014 11:11:53 -0700 Message-ID: <20140801181153.12496.71297.stgit@birch.djwong.org> In-Reply-To: <20140801181139.12496.14390.stgit@birch.djwong.org> References: <20140801181139.12496.14390.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Darrick J. Wong Don't allow critical metadata blocks to be marked free in the block found map. This can theoretically happen on an FS where a first inode's ETB/indirect map block is in the inode table, the first inode is itself unclonable (and thus gets deleted) and there are enough crosslinked files before and after the first inode to use up all the free blocks during pass 1b. (I do actually have a test FS image but it's 256M and it proved very difficult to craft a bite-sized test case that actually hit this bug.) Signed-off-by: Darrick J. Wong --- e2fsck/pass1.c | 7 +++++++ 1 file changed, 7 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 26fe60c..e7a6acd 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3356,6 +3356,13 @@ static void e2fsck_block_alloc_stats(ext2_filsys fs, blk64_t blk, int inuse) { e2fsck_t ctx = (e2fsck_t) fs->priv_data; + /* Never free a critical metadata block */ + if (ctx->block_found_map && + ctx->block_metadata_map && + inuse < 0 && + ext2fs_test_block_bitmap2(ctx->block_metadata_map, blk)) + return; + if (ctx->block_found_map) { if (inuse > 0) ext2fs_mark_block_bitmap2(ctx->block_found_map, blk);