From patchwork Sat Mar 10 22:47:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 884186 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mit.edu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=thunk.org header.i=@thunk.org header.b="oYUwjnU8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zzKC93cJ5z9tNs for ; Sun, 11 Mar 2018 09:47:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751199AbeCJWrq (ORCPT ); Sat, 10 Mar 2018 17:47:46 -0500 Received: from imap.thunk.org ([74.207.234.97]:52814 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbeCJWrq (ORCPT ); Sat, 10 Mar 2018 17:47:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9K0C4qBtDw8oPCVbbBCjIj7e+8hIqVM5flZSrQ7Don4=; b=oYUwjnU8u7hH73+8HdW7ymsAFo L83ci9gvP/u4H1sFtlB73+8ryTmeOTAwHMzwAHRzVQhaknnTb31KZ+5RvAsdbe5aoSH5w4KKwhG6v jpm7pBETANryuRDhNHPgXEzWRz/f+Hk1CyXZrLI3I5m6JhcRwhiusdIW4lHlYRr5Tu1k=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.89) (envelope-from ) id 1eunHD-0001Ko-LS; Sat, 10 Mar 2018 22:47:43 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id 85AB07A2F45; Sat, 10 Mar 2018 17:47:42 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List Cc: adilger@dilger.ca, lczerner@redhat.com, Theodore Ts'o Subject: [PATCH] e2fsck: fix endianness problem when reading htree nodes Date: Sat, 10 Mar 2018 17:47:33 -0500 Message-Id: <20180310224733.29843-1-tytso@mit.edu> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a In-Reply-To: <20180310212437.GB31151@thunk.org> References: <20180310212437.GB31151@thunk.org> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Lukas Czerner Wrong directory block number can be saved in ->previous on big endian system in parse_int_node(). Fix it by moving the mask out of the endian conversion. Fixes: ae9efd05a986 ("e2fsck: 3 level hash tree directory optimization") Signed-off-by: Lukas Czerner Signed-off-by: Theodore Ts'o Reviewed-by: Andreas Dilger --- e2fsck/pass2.c | 5 +++-- lib/ext2fs/ext2_fs.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 1b0504c85..e922876d3 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -643,7 +643,7 @@ static void parse_int_node(ext2_filsys fs, printf("Entry #%d: Hash 0x%08x, block %u\n", i, hash, ext2fs_le32_to_cpu(ent[i].block)); #endif - blk = ext2fs_le32_to_cpu(ent[i].block) & 0x0ffffff; + blk = ext2fs_le32_to_cpu(ent[i].block) & EXT4_DX_BLOCK_MASK; /* Check to make sure the block is valid */ if (blk >= (blk_t) dx_dir->numblocks) { cd->pctx.blk = blk; @@ -664,7 +664,8 @@ static void parse_int_node(ext2_filsys fs, } dx_db->previous = - i ? ext2fs_le32_to_cpu(ent[i-1].block & 0x0ffffff) : 0; + i ? (ext2fs_le32_to_cpu(ent[i-1].block) & + EXT4_DX_BLOCK_MASK) : 0; if (hash < min_hash) min_hash = hash; diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 2496d16da..7d6269413 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -232,6 +232,8 @@ struct ext2_dx_root_info { #define EXT2_HASH_FLAG_INCOMPAT 0x1 +#define EXT4_DX_BLOCK_MASK 0x0fffffff + struct ext2_dx_entry { __le32 hash; __le32 block;