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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 258CCC433F5 for ; Mon, 9 May 2022 01:26:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233731AbiEIBaA (ORCPT ); Sun, 8 May 2022 21:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235619AbiEIAph (ORCPT ); Sun, 8 May 2022 20:45:37 -0400 Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C6ECB658B for ; Sun, 8 May 2022 17:41:45 -0700 (PDT) Received: from dread.disaster.area (pa49-181-2-147.pa.nsw.optusnet.com.au [49.181.2.147]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id B7CF6534591 for ; Mon, 9 May 2022 10:41:41 +1000 (AEST) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1nnrT2-009hdc-Mm for linux-xfs@vger.kernel.org; Mon, 09 May 2022 10:41:40 +1000 Received: from dave by discord.disaster.area with local (Exim 4.95) (envelope-from ) id 1nnrT2-003CQM-Ld for linux-xfs@vger.kernel.org; Mon, 09 May 2022 10:41:40 +1000 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 18/18] xfs: detect empty attr leaf blocks in xfs_attr3_leaf_verify Date: Mon, 9 May 2022 10:41:38 +1000 Message-Id: <20220509004138.762556-19-david@fromorbit.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509004138.762556-1-david@fromorbit.com> References: <20220509004138.762556-1-david@fromorbit.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=VuxAv86n c=1 sm=1 tr=0 ts=62786345 a=ivVLWpVy4j68lT4lJFbQgw==:117 a=ivVLWpVy4j68lT4lJFbQgw==:17 a=oZkIemNP1mAA:10 a=20KFwNOVAAAA:8 a=j0Z8cYLM2iZn_fZ0F7kA:9 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner xfs_repair flags these as a corruption error, so the verifier should catch software bugs that result in empty leaf blocks being written to disk, too. Signed-off-by: Dave Chinner --- fs/xfs/libxfs/xfs_attr_leaf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index d15e92858bf0..15a990409463 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -310,6 +310,15 @@ xfs_attr3_leaf_verify( if (fa) return fa; + /* + * Empty leaf blocks should never occur; they imply the existence of a + * software bug that needs fixing. xfs_repair also flags them as a + * corruption that needs fixing, so we should never let these go to + * disk. + */ + if (ichdr.count == 0) + return __this_address; + /* * firstused is the block offset of the first name info structure. * Make sure it doesn't go off the block or crash into the header. -- 2.35.1