From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8B9DC43464 for ; Fri, 18 Sep 2020 02:45:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BB44214D8 for ; Fri, 18 Sep 2020 02:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600397109; bh=RlR1wWFouGEpAYZNFe6IH5bp8V7d1uaXy5ce9dG8gsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=J7Lkv+4rpfMK2YHLXfJ09UsqZ7zb1LI7C3QgXoWanGyCtUu67PnreuJR9p6+8CX91 kVlcGMua02vDqIYDgRHVJNYvbBwrIyAaWb/rtNriYROeRPzUtxSFhU3t6n889i/uHv b19cRYn1JmnN/vLScOtXbuuZVCwy4gnEZ6CTZCsg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbgIRCpI (ORCPT ); Thu, 17 Sep 2020 22:45:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728421AbgIRCKS (ORCPT ); Thu, 17 Sep 2020 22:10:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A9AF239EC; Fri, 18 Sep 2020 02:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395012; bh=RlR1wWFouGEpAYZNFe6IH5bp8V7d1uaXy5ce9dG8gsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nK4QtxYQm10fCYRoObsff6CDbitvuNGUHEPSJYDDaE5Y1RqP8Ywu7kVk/hPIKwbOt uoTg7qlrLTyvD9Xjdfs5fIe/gCps1qw15NbbyioikUBb4u5F1CGBp09GcsG32nZLo1 ergYSreI8ZSW0BCD17pg73xFPoepHOQy3DtRtLgo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Darrick J. Wong" , Dave Chinner , Sasha Levin , xfs@oss.sgi.com Subject: [PATCH AUTOSEL 4.19 107/206] xfs: mark dir corrupt when lookup-by-hash fails Date: Thu, 17 Sep 2020 22:06:23 -0400 Message-Id: <20200918020802.2065198-107-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Darrick J. Wong" [ Upstream commit 2e107cf869eecc770e3f630060bb4e5f547d0fd8 ] In xchk_dir_actor, we attempt to validate the directory hash structures by performing a directory entry lookup by (hashed) name. If the lookup returns ENOENT, that means that the hash information is corrupt. The _process_error functions don't catch this, so we have to add that explicitly. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Sasha Levin --- fs/xfs/scrub/dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c index cd3e4d768a18c..33dfcba72c7a0 100644 --- a/fs/xfs/scrub/dir.c +++ b/fs/xfs/scrub/dir.c @@ -156,6 +156,9 @@ xchk_dir_actor( xname.type = XFS_DIR3_FT_UNKNOWN; error = xfs_dir_lookup(sdc->sc->tp, ip, &xname, &lookup_ino, NULL); + /* ENOENT means the hash lookup failed and the dir is corrupt */ + if (error == -ENOENT) + error = -EFSCORRUPTED; if (!xchk_fblock_process_error(sdc->sc, XFS_DATA_FORK, offset, &error)) goto out; -- 2.25.1