From patchwork Thu Sep 1 00:38:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 112783 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 69C77B6F7B for ; Thu, 1 Sep 2011 10:38:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756849Ab1IAAid (ORCPT ); Wed, 31 Aug 2011 20:38:33 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:47102 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756685Ab1IAAic (ORCPT ); Wed, 31 Aug 2011 20:38:32 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p810ZDVF028978 for ; Wed, 31 Aug 2011 18:35:13 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p810cQut123278 for ; Wed, 31 Aug 2011 18:38:26 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p810cONr009830 for ; Wed, 31 Aug 2011 18:38:25 -0600 Received: from elm3c44.beaverton.ibm.com ([9.47.69.44]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p810cNdP009810; Wed, 31 Aug 2011 18:38:23 -0600 Subject: [PATCH 30/37] e2fsck: Check extended attribute block checksums To: Andreas Dilger , Theodore Tso , "Darrick J. Wong" From: "Darrick J. Wong" Cc: Sunil Mushran , Amir Goldstein , Andi Kleen , Mingming Cao , Joel Becker , linux-ext4@vger.kernel.org, Coly Li Date: Wed, 31 Aug 2011 17:38:23 -0700 Message-ID: <20110901003823.1176.78056.stgit@elm3c44.beaverton.ibm.com> In-Reply-To: <20110901003509.1176.51159.stgit@elm3c44.beaverton.ibm.com> References: <20110901003509.1176.51159.stgit@elm3c44.beaverton.ibm.com> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Verify the checksums of separate extended attribute blocks and offer to clear it if there is a mismatch. Signed-off-by: Darrick J. Wong --- e2fsck/pass1.c | 7 +++++++ e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ 3 files changed, 15 insertions(+), 0 deletions(-) -- 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 71cbddb..e4d4c78 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1555,7 +1555,9 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, * validate it */ pctx->blk = blk; + fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; pctx->errcode = ext2fs_read_ext_attr2(fs, blk, block_buf); + fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS; if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx)) goto clear_extattr; header = (struct ext2_ext_attr_header *) block_buf; @@ -1568,6 +1570,11 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, goto clear_extattr; } + if (!ext2fs_ext_attr_block_csum_verify(fs, pctx->blk, + (struct ext2_ext_attr_header *)block_buf) && + fix_problem(ctx, PR_1_EA_BLOCK_CSUM_INVALID, pctx)) + goto clear_extattr; + if (header->h_blocks != 1) { if (fix_problem(ctx, PR_1_EA_MULTI_BLOCK, pctx)) goto clear_extattr; diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 835f0ff..1259568 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -920,6 +920,11 @@ static struct e2fsck_problem problem_table[] = { N_("@i %i checksum should not be set. "), PROMPT_CLEAR, PR_PREEN_OK }, + /* Checksum failure reading extended attribute block */ + { PR_1_EA_BLOCK_CSUM_INVALID, + N_("Checksum failure @a @b %b for @i %i. "), + PROMPT_CLEAR, 0 }, + /* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index df29057..47e6904 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -538,6 +538,9 @@ struct problem_context { /* inode checksum should not be set */ #define PR_1_INODE_CSUM_NONZERO 0x010064 +/* ea block checksum invalid */ +#define PR_1_EA_BLOCK_CSUM_INVALID 0x010065 + /* * Pass 1b errors */