From: Darrick J. Wong Date: Fri, 26 Aug 2016 05:58:40 +0000 (+1000) Subject: xfs: don't perform lookups on zero-height btrees X-Git-Tag: v4.8-rc5~23^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed150e1a5cf20c04cf0b2d2c34e498fc1d6519be;p=platform%2Fkernel%2Flinux-exynos.git 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 Reviewed-by: Christoph Hellwig Signed-off-by: Dave Chinner --- diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index b5c213a..33f1406 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;