From patchwork Wed Mar 21 03:21:58 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: 10298479 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 291A9602B3 for ; Wed, 21 Mar 2018 03:23:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B8FB2976D for ; Wed, 21 Mar 2018 03:23:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A06329735; Wed, 21 Mar 2018 03:23:12 +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 0429F2976D for ; Wed, 21 Mar 2018 03:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbeCUDWB (ORCPT ); Tue, 20 Mar 2018 23:22:01 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:44564 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbeCUDWA (ORCPT ); Tue, 20 Mar 2018 23:22:00 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2L38qmd061351 for ; Wed, 21 Mar 2018 03:22:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=661kjhomkFV28zKcLUlLlpKw0uC7rM1WuhFaJr2O0R8=; b=Kcvm0I36q1/BxGZ4hynMTAANFKrxHpbNNsBF2PL4CAL8zxep6DNxeWnL/fpKwEJpEXhQ cyq3EbDiKrFofEYt5Tbaekpd9YWh7nMr9KxikMVZ6d5fzlFAwy/BDl0k02jTsIF88flM zUSSJM4kxfkLG0nPCLfbwh4gU8+AkGQOZEEbi7PGXlRvU+6YvrrpP2NhIafJOA37pa3F 8CAdMBXcykwUwDM9+RGQ97xjnx2raYokMYo3Zy7iYAygnrwq+t8PGzBDYO/gJCmXl7O1 DfPFN0gcuI3KoDazVF1WT3X06c46TuThks8gCeJTv57bTkuJSvNdwmGjyDlq1eyPSQP3 6w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2guf7x0137-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 21 Mar 2018 03:22:00 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2L3Lxs1031995 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 21 Mar 2018 03:21:59 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w2L3Lx1S008409 for ; Wed, 21 Mar 2018 03:21:59 GMT Received: from localhost (/10.159.242.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2018 20:21:59 -0700 Date: Tue, 20 Mar 2018 20:21:58 -0700 From: "Darrick J. Wong" To: linux-xfs@vger.kernel.org Subject: [PATCH 11/9] xfs: flag inode corruption if parent ptr doesn't get us a real inode Message-ID: <20180321032158.GR1757@magnolia> References: <152107377037.19571.8618901963505842632.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <152107377037.19571.8618901963505842632.stgit@magnolia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8838 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=416 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, flag the directory as corrupt. Enable IGET_UNTRUSTED here so that we can confirm with the inobt that the inode is present and allocated. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/scrub/parent.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 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..d1547ca 100644 --- a/fs/xfs/scrub/parent.c +++ b/fs/xfs/scrub/parent.c @@ -167,9 +167,14 @@ 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. */ - error = xfs_iget(mp, sc->tp, dnum, 0, 0, &dp); - if (!xfs_scrub_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error)) + error = xfs_iget(mp, sc->tp, dnum, XFS_IGET_UNTRUSTED, 0, &dp); + if (error == -EINVAL) + error = -EFSCORRUPTED; + if (!xfs_scrub_fblock_process_error(sc, XFS_DATA_FORK, 0, &error)) goto out; if (dp == sc->ip || !S_ISDIR(VFS_I(dp)->i_mode)) { xfs_scrub_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);