public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: "Darrick J . Wong" <darrick.wong@oracle.com>
Cc: Brian Foster <bfoster@redhat.com>, Christoph Hellwig <hch@lst.de>,
	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	[thread overview]
Message-ID: <1484062757-12433-7-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1484062757-12433-1-git-send-email-amir73il@gmail.com>

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(+)

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


  parent reply	other threads:[~2017-01-10 15:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 15:39 [PATCH v7 0/6] xfs: fixes for malformed on-disk i_mode Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 1/6] xfs: make the ASSERT() condition likely Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 2/6] xfs: sanity check directory inode di_size Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 3/6] xfs: add missing include dependencies to xfs_dir2.h Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 4/6] xfs: replace xfs_mode_to_ftype table with switch statement Amir Goldstein
2017-01-10 23:17   ` Darrick J. Wong
2017-01-10 15:39 ` [PATCH v7 5/6] xfs: sanity check inode mode when creating new dentry Amir Goldstein
2017-01-10 23:15   ` Darrick J. Wong
2017-01-11  5:08     ` Amir Goldstein
2017-01-11  7:50       ` Darrick J. Wong
2017-01-10 15:39 ` Amir Goldstein [this message]
2017-01-10 23:16   ` [PATCH v7 6/6] xfs: sanity check inode di_mode Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484062757-12433-7-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox