diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-08-26 07:58:40 +0200 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-08-26 07:58:40 +0200 |
commit | ed150e1a5cf20c04cf0b2d2c34e498fc1d6519be (patch) | |
tree | 867b5a19de18ad47ece6325be6ce8c6f986aaafd /fs | |
parent | Merge branch 'iomap-fixes-4.8-rc3' into for-next (diff) | |
download | linux-ed150e1a5cf20c04cf0b2d2c34e498fc1d6519be.tar.xz linux-ed150e1a5cf20c04cf0b2d2c34e498fc1d6519be.zip |
xfs: don't perform lookups on zero-height btrees
If the caller passes in a cursor to a zero-height btree (which is
impossible), we never set block to anything but NULL, which causes the
later dereference of it to crash. Instead, just return -EFSCORRUPTED.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_btree.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index b5c213a051cd..33f14067c320 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -1814,6 +1814,10 @@ xfs_btree_lookup( XFS_BTREE_STATS_INC(cur, lookup); + /* No such thing as a zero-level tree. */ + if (cur->bc_nlevels == 0) + return -EFSCORRUPTED; + block = NULL; keyno = 0; |