diff mbox

[v7,6/6] xfs: sanity check inode di_mode

Message ID 1484062757-12433-7-git-send-email-amir73il@gmail.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Amir Goldstein Jan. 10, 2017, 3:39 p.m. UTC
Check for invalid file type in xfs_dinode_verify()
and fail to load the inode structure from disk.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Darrick J. Wong Jan. 10, 2017, 11:16 p.m. UTC | #1
On Tue, Jan 10, 2017 at 05:39:17PM +0200, Amir Goldstein wrote:
> Check for invalid file type in xfs_dinode_verify()
> and fail to load the inode structure from disk.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)