From: Amir Goldstein Date: Thu, 26 Jan 2017 02:02:42 +0000 (-0600) Subject: xfs: sanity check inode di_mode X-Git-Tag: v4.10.0-rc1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0962b5b38330b5f371c1a2a3c9ae4754a4b93697;p=thirdparty%2Fxfsprogs-dev.git xfs: sanity check inode di_mode Source kernel commit: a324cbf10a3c67aaa10c9f47f7b5801562925bc2 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 Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 4c7be6761..da8ac96c1 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -27,6 +27,7 @@ #include "xfs_cksum.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 @@ -396,6 +397,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)