From patchwork Thu Mar 22 17:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10302057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E015160386 for ; Thu, 22 Mar 2018 17:58:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFE00286B9 for ; Thu, 22 Mar 2018 17:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C47A4286FF; Thu, 22 Mar 2018 17:58:06 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 3D368286B9 for ; Thu, 22 Mar 2018 17:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbeCVR6E (ORCPT ); Thu, 22 Mar 2018 13:58:04 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:40268 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751586AbeCVR6E (ORCPT ); Thu, 22 Mar 2018 13:58:04 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2MHfnWe097063; Thu, 22 Mar 2018 17:58:01 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-2017-10-26; bh=fyHFK/fksDr4mKu4wO62w8XvxHQS95Wybu5r7YJoOGA=; b=K8GwK5ShUpT4o/ijvgAvmkayvztemiXwvObNT+rdxNv4xTyhZwWy1OSKBchI+uXE7uls 7DXtsDzRBbgUL18Nbi7uZHTIlhY0pjsUY7uMyqAK80KmxTmGCrbSJp28sPSwUdAvjloY o3EZ5KgKImHQjauQZk906GNR3YnSEWC2GgqKnWOh2SID//Zr5BvCF9La+h7mbjYTP7GA V4MwcL2Y2zvrkmoeti5t5UdSaRNfsTa+CyFY6cJ/SuHESzakzSIute8No02wAEJxsoKT 1vlgG29guVYwjrtDbcz02F0UY+xVLWeTwgM8QqiOfPg7CstNy7EeknPHNcKndFlKYR+c jA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2gvh45r2jb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Mar 2018 17:58:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2MHw16I015663 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Mar 2018 17:58:01 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2MHw1Zh013110; Thu, 22 Mar 2018 17:58:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Mar 2018 10:58:00 -0700 Date: Thu, 22 Mar 2018 10:57:59 -0700 From: "Darrick J. Wong" To: linux-xfs@vger.kernel.org Cc: Brian Foster Subject: [PATCH v2 11/9] xfs: flag inode corruption if parent ptr doesn't get us a real inode Message-ID: <20180322175759.GA4818@magnolia> References: <152107377037.19571.8618901963505842632.stgit@magnolia> <20180321032158.GR1757@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180321032158.GR1757@magnolia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8839 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=462 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 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 If a directory's parent inode pointer doesn't point to an inode, the directory should be flagged as corrupt. Enable IGET_UNTRUSTED here so that _iget will return -EINVAL if the inobt does not confirm that the inode is present and allocated and we can flag the directory corruption. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- v2: we only want to flag EINVAL as a directory corruption, everything else is still a cross-referencing error --- fs/xfs/scrub/parent.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c index 0d38514..1fb88c1 100644 --- a/fs/xfs/scrub/parent.c +++ b/fs/xfs/scrub/parent.c @@ -167,8 +167,18 @@ xfs_scrub_parent_validate( * if the parent pointer erroneously points to a file, we * can't use DONTCACHE here because DONTCACHE inodes can trigger * immediate inactive cleanup of the inode. + * + * If _iget returns -EINVAL then the parent inode number is garbage + * and the directory is corrupt. If the _iget returns -EFSCORRUPTED + * or -EFSBADCRC then the parent is corrupt which is a cross + * referencing error. Any other error is an operational error. */ - error = xfs_iget(mp, sc->tp, dnum, 0, 0, &dp); + error = xfs_iget(mp, sc->tp, dnum, XFS_IGET_UNTRUSTED, 0, &dp); + if (error == -EINVAL) { + error = -EFSCORRUPTED; + xfs_scrub_fblock_process_error(sc, XFS_DATA_FORK, 0, &error); + goto out; + } if (!xfs_scrub_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error)) goto out; if (dp == sc->ip || !S_ISDIR(VFS_I(dp)->i_mode)) {