]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: convert a few more directory asserts to corruption
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 18 Apr 2018 19:46:06 +0000 (14:46 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 18 Apr 2018 19:46:06 +0000 (14:46 -0500)
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 <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
libxfs/xfs_dir2_leaf.c
libxfs/xfs_dir2_node.c

index 60f7eb29a94e8dc8a8bff0e9c641b2c0d42e642e..b42d9dbdf99fed9cf89b80e5b5b7c60c899866ad 100644 (file)
@@ -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.
         */
index 6d7986c99652fc796f992f4b51278274e784f202..97d42035b9f2872e047eafb61a895f4c9de0234a 100644 (file)
@@ -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.