From 574b41535bd2b2a07b5ffdf466a6bb4585907f3e Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 26 Aug 2016 11:16:41 +1000 Subject: [PATCH] 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 --- libxfs/xfs_btree.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- 2.47.2