From patchwork Tue Jan 15 22:42:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10765207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C34D1580 for ; Tue, 15 Jan 2019 22:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 894912E12A for ; Tue, 15 Jan 2019 22:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CB902E133; Tue, 15 Jan 2019 22:43:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D82F2E12A for ; Tue, 15 Jan 2019 22:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387508AbfAOWnA (ORCPT ); Tue, 15 Jan 2019 17:43:00 -0500 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 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0FMcvOS128259; Tue, 15 Jan 2019 22:42:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=QfhzqZqJNKNpRzEDpTHCDN8rfv7dMvi8CvFhHQVRNlI=; b=5pMCcSMT2kEYDF1CrWgEWdjfltX/IgZSOaa7Vqhm0gDN8S/sr7N+00hpThqgnNzJs9N6 KF8zEfanSwW19JiyNZukw5Z3NmZ3Z30CGFW/xIffm+v7MNY077N/UuWNBJNiMAkRN+qw 2lx+oBbNIyei9bhvnb+PTP3C7Gf/oRqPSVjc/T1zwAzoW4KdmkE6AR+j7otisc5vclj4 kavWjNwham1e6EuNOjBeGLdXzVpNpiey+r1M5FE5texyVkEj3voozXWjURfrACWtLCvT wYvxpBiy2I5q/1OgnmlQRW5cUvKU+7eLT8W+OMRou2zSn0xjKgnMLqnj6i9ppNs0UFpI wg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2pybkcepq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Jan 2019 22:42:58 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0FMgv8u006035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Jan 2019 22:42:57 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0FMgvCD024578; Tue, 15 Jan 2019 22:42:57 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Jan 2019 14:42:57 -0800 Date: Tue, 15 Jan 2019 14:42:56 -0800 From: "Darrick J. Wong" To: xfs Cc: Dave Chinner 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-Disposition: inline In-Reply-To: <20190115170820.GB12689@magnolia> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9137 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901150179 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Dave Chinner --- 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");