From: Darrick J. Wong Date: Thu, 28 Jun 2018 20:11:57 +0000 (-0500) Subject: xfs: btree lookup shouldn't ASSERT on empty btree nodes X-Git-Tag: v4.18.0-rc0~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e64ec0d5f0d333500d7d2fcc4520943e87e6220;p=thirdparty%2Fxfsprogs-dev.git xfs: btree lookup shouldn't ASSERT on empty btree nodes Source kernel commit: eeee0d6a9bc93eaa211918c203fde263d44fa20e If a btree lookup encounters an empty btree node or an empty btree leaf on a multi-level btree, that's evidence of a corrupt on-disk btree. Therefore, we should return -EFSCORRUPTED to the upper levels, not an ASSERT failure. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 2bd9dd359..d64cd2899 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -1892,7 +1892,12 @@ xfs_btree_lookup( high = xfs_btree_get_numrecs(block); if (!high) { /* Block is empty, must be an empty leaf. */ - ASSERT(level == 0 && cur->bc_nlevels == 1); + if (level != 0 || cur->bc_nlevels != 1) { + XFS_CORRUPTION_ERROR(__func__, + XFS_ERRLEVEL_LOW, + cur->bc_mp, block); + return -EFSCORRUPTED; + } cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; *stat = 0;