From patchwork Wed Jan 11 08:24:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9509477 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 7FA5660762 for ; Wed, 11 Jan 2017 08:24:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E9DD285E5 for ; Wed, 11 Jan 2017 08:24:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63820285ED; Wed, 11 Jan 2017 08:24:40 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 0806B285EE for ; Wed, 11 Jan 2017 08:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936356AbdAKIYj (ORCPT ); Wed, 11 Jan 2017 03:24:39 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34122 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933704AbdAKIYi (ORCPT ); Wed, 11 Jan 2017 03:24:38 -0500 Received: by mail-wm0-f65.google.com with SMTP id c85so35008049wmi.1 for ; Wed, 11 Jan 2017 00:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/+vn92J2jHJro6a6vnjFcW88KYXs+7ZgPvtJ12kklAw=; b=BVJ/OQYeh3/+Ej18LpO1pjMj72UX+tjsajYlL6WXRSAedN1Rk938e4pkylLdihyAUx fG/OaF1uPoEtWkCjNWjs0KTc8Gd35ZWz2uguccfwWNbPXeGlqqDziRsjmgGa4ypiJZsc I74X5TfLE62bEbDI7qRnbmHxELsydfve9JMmNcpi926FE/VkY1N5KhOwf0zYMR4jvmXQ 8Ip/7H4NImZyH/PcEe/TwR/X880am5GlE8UpFwDorc8OgYcRxzNNPlqbpAm/zzzvDjtP Y17cSs71eyJA2OESqCjrvXSyLCdTWSvRxxGy0a0ZAQl3JCGy3FAkODxigou/oJiFd1MI qCgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/+vn92J2jHJro6a6vnjFcW88KYXs+7ZgPvtJ12kklAw=; b=lYfPiXegPUzdGRIzJaPkLCb4NvoGOa8EIbgf/8KAF/AcTwI+83aHM9pyxedYCeX9+A UrYlgWAZLxSTxNEqsjZqUoP4r90N7/bpfj99063617kieJu8BqM+abIDG30BaFyyPyVR 8kkkXx1YIQVsNfBIwAbTTaXl61S5MqlPT/h2BFyoogmtxY+lXKNgUIQt7kdH2kZrX9z3 2r7fr317fjQHt5iz4zCP0YCKlb9cuW1kgfbbxrO51ROncKfrfMIGw0GJRsXu963LnfiB sIhKTiZo/Iri4Z5ggCxS0WiqxrDcsTP13wCzZybRtt0QGERXxori7tp7pZzCXiReNHh9 nWdA== X-Gm-Message-State: AIkVDXK8wtml2lydbGw+ib5HUkWdSrarJwdp7QcfCCh1e3cjVvgMEMNmHHHYjqw/LrBHyQ== X-Received: by 10.28.1.216 with SMTP id 207mr4345141wmb.7.1484123076986; Wed, 11 Jan 2017 00:24:36 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-82-81-193-202.cablep.bezeqint.net. [82.81.193.202]) by smtp.gmail.com with ESMTPSA id l187sm7704670wml.6.2017.01.11.00.24.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 00:24:36 -0800 (PST) From: Amir Goldstein To: "Darrick J . Wong" Cc: Brian Foster , Christoph Hellwig , linux-xfs@vger.kernel.org Subject: [PATCH v8 6/6] xfs: sanity check inode di_mode Date: Wed, 11 Jan 2017 10:24:10 +0200 Message-Id: <1484123050-11064-7-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484123050-11064-1-git-send-email-amir73il@gmail.com> References: <1484123050-11064-1-git-send-email-amir73il@gmail.com> 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 Check for invalid file type in xfs_dinode_verify() and fail to load the inode structure from disk. Reviewed-by: Darrick J. Wong Signed-off-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_inode_buf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 0091ac3..d93f9d9 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -29,6 +29,7 @@ #include "xfs_icache.h" #include "xfs_trans.h" #include "xfs_ialloc.h" +#include "xfs_dir2.h" /* * Check that none of the inode's in the buffer have a next @@ -398,6 +399,8 @@ xfs_dinode_verify( return false; mode = be16_to_cpu(dip->di_mode); + if (mode && xfs_mode_to_ftype(mode) == XFS_DIR3_FT_UNKNOWN) + return false; /* No zero-length symlinks/dirs. */ if ((S_ISLNK(mode) || S_ISDIR(mode)) && dip->di_size == 0)