From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) From: Amir Goldstein 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> 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 List-ID: List-Id: xfs To: "Darrick J . Wong" Cc: Brian Foster , Christoph Hellwig , linux-xfs@vger.kernel.org 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 --- 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) -- 2.7.4