From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2130.oracle.com ([156.151.31.86]:59530 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729846AbfAOWnA (ORCPT ); Tue, 15 Jan 2019 17:43:00 -0500 Date: Tue, 15 Jan 2019 14:42:56 -0800 From: "Darrick J. Wong" Subject: [PATCH v2] xfs: don't crash when read verifier reports errors with null b_ops Message-ID: <20190115224256.GF12689@magnolia> References: <20190115170820.GB12689@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115170820.GB12689@magnolia> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: xfs Cc: Dave Chinner From: Darrick J. Wong In xrep_findroot_block, we work out the btree type and correctness of a given block by calling different btree verifiers on root block candidates. However, we leave the NULL b_ops while ->verify_read validates the block, which means that if the verifier calls xfs_buf_verifier_error it'll crash on the null b_ops. Fix it to avoid this crash. Signed-off-by: Darrick J. Wong --- v2: leave a comment about what we're doing above the function --- fs/xfs/xfs_error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 9866f542e77b..6e80e438b27a 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -340,6 +340,9 @@ xfs_corruption_error( /* * Warnings specifically for verifier errors. Differentiate CRC vs. invalid * values, and omit the stack trace unless the error level is tuned high. + * + * NOTE: Some callers might be calling the verifiers directly (rather than + * through the b_ops structure) so bp->b_ops may be NULL. */ void xfs_buf_verifier_error( @@ -359,7 +362,7 @@ xfs_buf_verifier_error( xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s", bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", - fa, bp->b_ops->name, bp->b_bn, name); + fa, bp->b_ops ? bp->b_ops->name : "unknown", bp->b_bn, name); xfs_alert(mp, "Unmount and run xfs_repair");