]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: double-check with shortform attr verifiers
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 23:07:45 +0000 (16:07 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 17 Apr 2024 21:06:27 +0000 (14:06 -0700)
Call the shortform attr structure verifier as the last thing we do in
process_shortform_attr to make sure that we don't leave any latent
errors for the kernel to stumble over.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
repair/attr_repair.c

index 01e4afb90d5c849183c2782ab3fa0ad3cee989c9..f117f9aef9ce364ac42f38cc22258140c3642363 100644 (file)
@@ -212,6 +212,7 @@ process_shortform_attr(
 {
        struct xfs_attr_sf_hdr          *hdr = XFS_DFORK_APTR(dip);
        struct xfs_attr_sf_entry        *currententry, *nextentry, *tempentry;
+       xfs_failaddr_t                  fa;
        int                             i, junkit;
        int                             currentsize, remainingspace;
 
@@ -373,6 +374,22 @@ process_shortform_attr(
                }
        }
 
+       fa = libxfs_attr_shortform_verify(hdr, be16_to_cpu(hdr->totsize));
+       if (fa) {
+               if (no_modify) {
+                       do_warn(
+       _("inode %" PRIu64 " shortform attr verifier failure, would have cleared attrs\n"),
+                               ino);
+               } else {
+                       do_warn(
+       _("inode %" PRIu64 " shortform attr verifier failure, cleared attrs\n"),
+                               ino);
+                       hdr->count = 0;
+                       hdr->totsize = cpu_to_be16(sizeof(struct xfs_attr_sf_hdr));
+                       *repair = 1;
+               }
+       }
+
        return(*repair);
 }