]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: detect empty attr leaf blocks in xfs_attr3_leaf_verify
authorDave Chinner <dchinner@redhat.com>
Wed, 22 Jun 2022 19:28:52 +0000 (14:28 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 22 Jun 2022 19:28:52 +0000 (14:28 -0500)
Source kernel commit: 51e6104fdb95f377c8741794778319bd413f4fff

xfs_repair flags these as a corruption error, so the verifier should
catch software bugs that result in empty leaf blocks being written
to disk, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr_leaf.c

index 04f34d0ee6ba1d9043f5e2add806373d99490d0e..75b8f08edfeb82bc2004f12390ae2f87990c4466 100644 (file)
@@ -307,6 +307,15 @@ xfs_attr3_leaf_verify(
        if (fa)
                return fa;
 
+       /*
+        * Empty leaf blocks should never occur;  they imply the existence of a
+        * software bug that needs fixing. xfs_repair also flags them as a
+        * corruption that needs fixing, so we should never let these go to
+        * disk.
+        */
+       if (ichdr.count == 0)
+               return __this_address;
+
        /*
         * firstused is the block offset of the first name info structure.
         * Make sure it doesn't go off the block or crash into the header.