From patchwork Wed May 8 22:02:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 242649 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 BF28F2C00C6 for ; Thu, 9 May 2013 08:02:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444Ab3EHWCy (ORCPT ); Wed, 8 May 2013 18:02:54 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:42503 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752748Ab3EHWCx (ORCPT ); Wed, 8 May 2013 18:02:53 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r48M2pps030909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 May 2013 22:02:52 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r48M2oAq026254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 8 May 2013 22:02:51 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r48M2oIM005239; Wed, 8 May 2013 22:02:50 GMT Received: from localhost (/67.171.138.228) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 08 May 2013 15:02:50 -0700 Date: Wed, 8 May 2013 15:02:49 -0700 From: "Darrick J. Wong" To: "Theodore Ts'o" Cc: linux-ext4 Subject: [PATCH] e2fsck: Fix journal block tag checksum verification Message-ID: <20130508220249.GA8371@blackbox.djwong.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Al Viro complained of a ton of bogosity with regards to the jbd2 block tag header checksum. This one checksum is 16 bits, so cut off the upper 16 bits and treat it as a 16-bit value and don't mess around with be32* conversions. Fortunately metadata checksumming is still "experimental" and not in a shipping e2fsprogs, so there should be few users affected by this. This is the e2fsprogs version of the kernel patch. Reported-by: Al Viro Signed-off-by: Darrick J. Wong --- e2fsck/recovery.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 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/recovery.c b/e2fsck/recovery.c index 69ed68a..5af3e7b 100644 --- a/e2fsck/recovery.c +++ b/e2fsck/recovery.c @@ -395,7 +395,8 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf) static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, void *buf, __u32 sequence) { - __u32 provided, calculated; + __u32 calculated; + __u16 provided, crc; if (!JFS_HAS_INCOMPAT_FEATURE(j, JFS_FEATURE_INCOMPAT_CSUM_V2)) return 1; @@ -406,9 +407,10 @@ static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, calculated = ext2fs_crc32c_le(calculated, (__u8 *)&sequence, sizeof(sequence)); calculated = ext2fs_crc32c_le(calculated, buf, j->j_blocksize) & 0xffff; + crc = calculated & 0xFFFF; provided = ext2fs_be16_to_cpu(tag->t_checksum); - return provided == ext2fs_cpu_to_be32(calculated); + return provided == crc; } static int do_one_pass(journal_t *journal,