From patchwork Tue May 8 16:31:24 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: 10386519 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 B463960236 for ; Tue, 8 May 2018 16:31:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0D4828E78 for ; Tue, 8 May 2018 16:31:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9300528F7C; Tue, 8 May 2018 16:31:46 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 171DB28E78 for ; Tue, 8 May 2018 16:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755368AbeEHQbp (ORCPT ); Tue, 8 May 2018 12:31:45 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40966 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754736AbeEHQbo (ORCPT ); Tue, 8 May 2018 12:31:44 -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 w48GUiNK026304; Tue, 8 May 2018 16:31:27 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=FaAhSprRmYT3vZv+RhqcjK1m0sdVuQivNrNtXY03eYU=; b=GaBrAFkle3f2b1VoR4gLY4Dam2VPC2G30WZajBM1OKKE6D1t0hs72TPTIJcZ1mKSHmNo jefNpEPUs6GtV763TciX93lBzP67e73v1stQxqsU2R3Xss3weVzK/jbrVEIzz+7aUdDo AsFFJ8mp41YWw72yn/1XDSi4raGU0w6dG66QAJbmr3zFPdsasLQn0/GulaHsgb8kzxMF m31GPxICtTzzZOjc1A0QNs9HronWPt1+efBDjoRAD/4R15GNihlTUFhMenyUh2LqI39Y h0eZgQEZi9fu42k+KCf/IE7X6i+IgxFjQwEKHNzZJdYY8UxSKbCHEkL4u/ouDzQMF1+b /A== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2hs5939edx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 May 2018 16:31:27 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w48GVQdp011135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 May 2018 16:31:26 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w48GVPhk017646; Tue, 8 May 2018 16:31:26 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 May 2018 09:31:25 -0700 Date: Tue, 8 May 2018 09:31:24 -0700 From: "Darrick J. Wong" To: sandeen@redhat.com Cc: linux-xfs@vger.kernel.org Subject: [PATCH v2 09/11] xfs_repair: actually fix .. entries that point to inode zero Message-ID: <20180508163124.GM11261@magnolia> References: <152401958920.13319.10756339531174871801.stgit@magnolia> <152401964787.13319.7143262291746238151.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <152401964787.13319.7143262291746238151.stgit@magnolia> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8887 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=860 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805080159 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 we encounter a directory with an entry that points to inode zero, we'll crash due to an ASSERT during process_inode_chunk. This is due to process_dir2_data not arranging for phase 6 to fix the parent pointer when '..' -> 0, so do that. Found via xfs/386 fuzzing bu[1].inumber to zero. Signed-off-by: Darrick J. Wong --- libxfs/libxfs_api_defs.h | 1 + repair/dir2.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) -- 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/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index d588f342..56f9f8ca 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -78,6 +78,7 @@ #define xfs_bmbt_get_all libxfs_bmbt_get_all #define xfs_rtfree_extent libxfs_rtfree_extent #define xfs_verify_rtbno libxfs_verify_rtbno +#define xfs_verify_ino libxfs_verify_ino #define xfs_zero_extent libxfs_zero_extent #define xfs_defer_init libxfs_defer_init diff --git a/repair/dir2.c b/repair/dir2.c index fbe88b50..f0371371 100644 --- a/repair/dir2.c +++ b/repair/dir2.c @@ -847,6 +847,23 @@ _("bad .. entry in root directory inode %" PRIu64 ", was %" PRIu64 ": "), } *parent = ino; } + /* + * Make sure our parent pointer doesn't point + * off into space. + */ + if (!junkit && + *parent != NULLFSINO && + !libxfs_verify_ino(mp, *parent)) { + do_warn( +_("bad .. entry in directory inode %" PRIu64 ", was %" PRIu64 ": "), + ino, *parent); + if (!no_modify) { + do_warn(_("correcting\n")); + } else { + do_warn(_("would correct\n")); + } + *parent = NULLFSINO; + } } /* * Can't fix the directory unless we know which ..