Skip to content

Commit

Permalink
xfs: don't perform lookups on zero-height btrees
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
djwong authored and dchinner committed Aug 26, 2016
1 parent 32438cf commit ed150e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/xfs/libxfs/xfs_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ed150e1

Please sign in to comment.