From: Darrick J. Wong Date: Fri, 26 Aug 2016 01:16:41 +0000 (+1000) Subject: xfs: don't perform lookups on zero-height btrees X-Git-Tag: v4.8.0-rc1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=574b41535bd2b2a07b5ffdf466a6bb4585907f3e;p=thirdparty%2Fxfsprogs-dev.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/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 8391078f3..cb671f654 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -1810,6 +1810,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;