linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: verify size-vs-format for symlinks & dirs
@ 2018-08-26 20:31 Eric Sandeen
  2018-08-27  1:43 ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2018-08-26 20:31 UTC (permalink / raw)
  To: linux-xfs; +Cc: Xu, Wen

Today, xfs_ifork_verify_data() will simply skip verification if the inode
claims to be in non-local format.  However, nothing catches the case where
the size for the format is too small to be non-local.  xfs_repair tests
for this mismatch in process_check_inode_sizes(), so do the same in this
verifier.

Reported-by: Xu, Wen <wen.xu@gatech.edu>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200925
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index f9acf1d436f6..e032986d3f67 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -704,12 +704,21 @@ xfs_ifork_verify_data(
 	struct xfs_inode	*ip,
 	struct xfs_ifork_ops	*ops)
 {
-	/* Non-local data fork, we're done. */
-	if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
-		return NULL;
+	int			mode = VFS_I(ip)->i_mode;
+
+	if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) {
+		/* Small size for dir & symlink must be local */
+		if ((S_ISDIR(mode) || S_ISLNK(mode)) &&
+		    (ip->i_d.di_size <= XFS_IFORK_DSIZE(ip))) {
+			return __this_address;
+		} else {
+			/* Non-local data fork, we're done. */
+			return NULL;
+		}
+	}
 
 	/* Check the inline data fork if there is one. */
-	switch (VFS_I(ip)->i_mode & S_IFMT) {
+	switch (mode & S_IFMT) {
 	case S_IFDIR:
 		return ops->verify_dir(ip);
 	case S_IFLNK:

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-27  8:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-26 20:31 [PATCH] xfs: verify size-vs-format for symlinks & dirs Eric Sandeen
2018-08-27  1:43 ` Dave Chinner
2018-08-27  2:19   ` Eric Sandeen
2018-08-27  4:41     ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).