From patchwork Wed Apr 18 02:46:50 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: 10347273 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 55EC460244 for ; Wed, 18 Apr 2018 02:47:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4931127F7F for ; Wed, 18 Apr 2018 02:47:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E07C2834A; Wed, 18 Apr 2018 02:47:11 +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 D556727F7F for ; Wed, 18 Apr 2018 02:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753076AbeDRCrK (ORCPT ); Tue, 17 Apr 2018 22:47:10 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46950 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753141AbeDRCrJ (ORCPT ); Tue, 17 Apr 2018 22:47:09 -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 w3I2kqIF048797; Wed, 18 Apr 2018 02:46:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=NigV6njI9iTu1eop/kJba97CBdndoN2KUkpd2pzQTOM=; b=GgPJiwpJ1fUHza86QpwETV2mS79/jZHA6L8jRg40knt9qSvCuvIPwJSQl0iGuVEaUllk Uy2Qswg0Eka4r9gohdCwu669HaS2MQ3PLxPU8Yuc67Gq/M5nX3wxHXPZYW4Te5Oiy9VG ljNOsCo+dAr7ZdBvA8eFP70v0Hj90ZZX+C7H/4EdNZIy5KlUWuEbB6QjUlmrc+X3+tW1 GZOfuAJdHlkPYTW0csqnFJ39X5NwuVFoxWTW9VoTR3LSbcWtBNCgwfRRlPjMS2aurTu5 nqFIIw3c8Y7J8blpgcn0pvf2rPMoaJ61/75GNFBMLWl06h1S54yqVl/TjRmpyoVtDFTn RQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2hdrxp0kar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Apr 2018 02:46:52 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3I2kqSO028066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Apr 2018 02:46:52 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3I2kqTO029009; Wed, 18 Apr 2018 02:46:52 GMT Received: from localhost (/10.159.132.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Apr 2018 19:46:51 -0700 Subject: [PATCH 03/11] xfs_repair: validate some of the log space information From: "Darrick J. Wong" To: sandeen@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Tue, 17 Apr 2018 19:46:50 -0700 Message-ID: <152401961080.13319.3976228325503296406.stgit@magnolia> In-Reply-To: <152401958920.13319.10756339531174871801.stgit@magnolia> References: <152401958920.13319.10756339531174871801.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8866 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=884 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804180024 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 Validate the log space information in a similar manner to the kernel so that repair will stumble over (and fix) broken log info that prevents mounting. Fixes logsunit fuzz-and-fix failures in xfs/350. Signed-off-by: Darrick J. Wong --- repair/sb.c | 24 +++++++++++++++++++++++- 1 file changed, 23 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/repair/sb.c b/repair/sb.c index 3dc6538..f2968cd 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -299,6 +299,27 @@ sb_validate_ino_align(struct xfs_sb *sb) } /* + * Validate the given log space. Derived from xfs_log_mount, though we + * can't validate the minimum log size until later. + * Returns false if the log is garbage. + */ +static bool +verify_sb_loginfo( + struct xfs_sb *sb) +{ + if (xfs_sb_version_hascrc(sb) && + (sb->sb_logblocks == 0 || + sb->sb_logblocks > XFS_MAX_LOG_BLOCKS || + (sb->sb_logblocks << sb->sb_blocklog) > XFS_MAX_LOG_BYTES)) + return false; + + if (sb->sb_logsunit > 1 && sb->sb_logsunit % sb->sb_blocksize) + return false; + + return true; +} + +/* * verify a superblock -- does not verify root inode # * can only check that geometry info is internally * consistent. because of growfs, that's no guarantee @@ -409,7 +430,8 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb) sb->sb_inodesize != (1 << sb->sb_inodelog) || sb->sb_logsunit > XLOG_MAX_RECORD_BSIZE || sb->sb_inopblock != howmany(sb->sb_blocksize, sb->sb_inodesize) || - (sb->sb_blocklog - sb->sb_inodelog != sb->sb_inopblog)) + (sb->sb_blocklog - sb->sb_inodelog != sb->sb_inopblog) || + !verify_sb_loginfo(sb)) return XR_BAD_INO_SIZE_DATA; if (xfs_sb_version_hassector(sb)) {