]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: sanity check inode di_mode
authorAmir Goldstein <amir73il@gmail.com>
Thu, 26 Jan 2017 02:02:42 +0000 (20:02 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 26 Jan 2017 02:02:42 +0000 (20:02 -0600)
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 <darrick.wong@oracle.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_inode_buf.c

index 4c7be676175e782ca9b1de8e723fecff0763cf65..da8ac96c19c08fd227fdcd9608c2ea4591d3af34 100644 (file)
@@ -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)