diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-01-09 10:38:56 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-12 05:39:43 -0500 |
commit | f8b20705a383357ddca04ea648a7ac8fccd438ef (patch) | |
tree | 7a6df3b6f9ed6daeb677e238120d4bb6f714db70 /fs | |
parent | 12815dd15c480c0d595401e4eec54542025607f6 (diff) |
xfs: don't allow di_size with high bit set
commit ef388e2054feedaeb05399ed654bdb06f385d294 upstream.
The on-disk field di_size is used to set i_size, which is a signed
integer of loff_t. If the high bit of di_size is set, we'll end up with
a negative i_size, which will cause all sorts of problems. Since the
VFS won't let us create a file with such length, we should catch them
here in the verifier too.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_inode_buf.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 134424fac434..c906e50515f0 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c | |||
@@ -392,6 +392,14 @@ xfs_dinode_verify( | |||
392 | if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) | 392 | if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) |
393 | return false; | 393 | return false; |
394 | 394 | ||
395 | /* don't allow invalid i_size */ | ||
396 | if (be64_to_cpu(dip->di_size) & (1ULL << 63)) | ||
397 | return false; | ||
398 | |||
399 | /* No zero-length symlinks. */ | ||
400 | if (S_ISLNK(be16_to_cpu(dip->di_mode)) && dip->di_size == 0) | ||
401 | return false; | ||
402 | |||
395 | /* only version 3 or greater inodes are extensively verified here */ | 403 | /* only version 3 or greater inodes are extensively verified here */ |
396 | if (dip->di_version < 3) | 404 | if (dip->di_version < 3) |
397 | return true; | 405 | return true; |