From: Darrick J. Wong Date: Wed, 18 Apr 2018 19:46:06 +0000 (-0500) Subject: xfs: convert a few more directory asserts to corruption X-Git-Tag: v4.17.0-rc1~44^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6da71a852ba902a83cb1641109c3b9d0694c9d00;p=thirdparty%2Fxfsprogs-dev.git xfs: convert a few more directory asserts to corruption Source kernel commit: 3f883f5bb197b6fe4e6f461362782aa7b0e89cb6 Yet another round of playing whack-a-mole with directory code that asserts on corrupt on-disk metadata when it really should be returning -EFSCORRUPTED instead of ASSERTing. Found by a xfs/391 crash while lastbit fuzzing of ltail.bestcount. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index 60f7eb29a..b42d9dbdf 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -1412,7 +1412,8 @@ xfs_dir2_leaf_removename( oldbest = be16_to_cpu(bf[0].length); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf); bestsp = xfs_dir2_leaf_bests_p(ltp); - ASSERT(be16_to_cpu(bestsp[db]) == oldbest); + if (be16_to_cpu(bestsp[db]) != oldbest) + return -EFSCORRUPTED; /* * Mark the former data entry unused. */ diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 6d7986c99..97d42035b 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -384,8 +384,9 @@ xfs_dir2_leaf_to_node( dp->d_ops->free_hdr_from_disk(&freehdr, free); leaf = lbp->b_addr; ltp = xfs_dir2_leaf_tail_p(args->geo, leaf); - ASSERT(be32_to_cpu(ltp->bestcount) <= - (uint)dp->i_d.di_size / args->geo->blksize); + if (be32_to_cpu(ltp->bestcount) > + (uint)dp->i_d.di_size / args->geo->blksize) + return -EFSCORRUPTED; /* * Copy freespace entries from the leaf block to the new block.