summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_dir2_node.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-03-06 17:08:31 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2018-03-11 20:27:56 -0700
commit3f883f5bb197b6fe4e6f461362782aa7b0e89cb6 (patch)
treebe146062a5e804c86fae83990f4f838748253ff1 /fs/xfs/libxfs/xfs_dir2_node.c
parent8241f7f983b972823431d762f7c3c9fe0f2a7b00 (diff)
downloadlinux-3f883f5bb197b6fe4e6f461362782aa7b0e89cb6.tar.gz
linux-3f883f5bb197b6fe4e6f461362782aa7b0e89cb6.tar.bz2
linux-3f883f5bb197b6fe4e6f461362782aa7b0e89cb6.zip
xfs: convert a few more directory asserts to corruption
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 <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_dir2_node.c')
-rw-r--r--fs/xfs/libxfs/xfs_dir2_node.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 239d97a64296..0839ffe27e02 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -387,8 +387,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.