From patchwork Tue Jan 10 15:39:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9508045 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 E44C3601EA for ; Tue, 10 Jan 2017 15:39:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7D7D2858A for ; Tue, 10 Jan 2017 15:39:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCB4F285AC; Tue, 10 Jan 2017 15:39: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 6D4692858A for ; Tue, 10 Jan 2017 15:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939187AbdAJPjj (ORCPT ); Tue, 10 Jan 2017 10:39:39 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:35232 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939184AbdAJPjj (ORCPT ); Tue, 10 Jan 2017 10:39:39 -0500 Received: by mail-wj0-f195.google.com with SMTP id ey1so8844041wjd.2 for ; Tue, 10 Jan 2017 07:39:38 -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=MLPsrNeAYbKv/rAEWlNx9tW6289GmQ7M5ucqoN+xOFQ=; b=hIIdsDgz+R+UgdvZOVoCu2bubXzQjvKKu9gnn4KomfKvtU3t7/CGwHssxSme0LJ4qV qD6CL/Q7kubnVnSEG5JPX2M7zNmZRJMzXEeSNBe113X0MKwF37yxobArDggfB45gaInn Vo03f/WxAvsoj2oAfo4ZCKw8tyZJ8YELEWx9TOesQ8T7Vo1Z/bQ4mjdzHA1xi2hYVvR1 4apVLOYiqR7xwBOR0VgsdT4jCwJsz1ZnNiNZkLzddcinlLOmezx0qbmYx92YU5gWXasz WFoVYIMIB51hgMGj8aHvuLsuMcpjnJ+Dcqus9mDqrHTYPYpkXugu6wvKxN9cElwbMag3 vOqw== 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=MLPsrNeAYbKv/rAEWlNx9tW6289GmQ7M5ucqoN+xOFQ=; b=K45zcWPKCvZX0p2ClAxVV7BBWrcJDWeGHFBgrgLIYm1G5jbW+Yi/VV1A1fwPfSc92e I3FMhuKfHi1Kh861Az5E5jpy+oNFnruhBgqxe9h2yvVmXQeh9tTm2oEJOnpeXObktAL4 zBLGn/e2yqqdzYGzfQuU52HorEkWp/de3BtPVozxbHM977Usy3egrll9+QjB/21fEyJc 2endGX5wvRUSq9aFZK68JH09hujyg8dLXCi4ZtUtjUmcP9yMHYlyxpxkJ3PteiqThjG3 9ySHIavI7yfsBWDEkERoBgfHrI+wLZ2YNjB5uF0irUDka+8606X841S+DfsFoUMCg1uE FJxA== X-Gm-Message-State: AIkVDXL4yTBIjJz/FYqfYk+aZ9KiXkjDUggDo/2wtGO5vdOqzfQciB090TITrZkEXeu1Pg== X-Received: by 10.194.205.129 with SMTP id lg1mr2554734wjc.175.1484062777690; Tue, 10 Jan 2017 07:39:37 -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 cs4sm3792374wjd.42.2017.01.10.07.39.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jan 2017 07:39:37 -0800 (PST) From: Amir Goldstein To: "Darrick J . Wong" Cc: Brian Foster , Christoph Hellwig , linux-xfs@vger.kernel.org Subject: [PATCH v7 6/6] xfs: sanity check inode di_mode Date: Tue, 10 Jan 2017 17:39:17 +0200 Message-Id: <1484062757-12433-7-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484062757-12433-1-git-send-email-amir73il@gmail.com> References: <1484062757-12433-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. Signed-off-by: Amir Goldstein Reviewed-by: Darrick J. Wong --- 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)