]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: detect and fix padding fields that changed with nrext64
authorDarrick J. Wong <djwong@kernel.org>
Tue, 12 Jul 2022 18:27:33 +0000 (13:27 -0500)
committerEric Sandeen <sandeen@redhat.com>
Tue, 12 Jul 2022 18:27:33 +0000 (13:27 -0500)
Detect incorrectly set padding fields when large extent counts are
enabled or disabled on v3 inodes.

Found by fuzzing v3.flags2 = zeroes with xfs/374 and an nrext64=1
filesystem.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/dinode.c

index 7610cd45659b50967fdc38a1735073000143abce..fa841fbaa2f9d84f9cd568696ea63ffd609d33ff 100644 (file)
@@ -2703,6 +2703,26 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
                                *dirty = 1;
                }
 
+               if (xfs_dinode_has_large_extent_counts(dino)) {
+                       if (dino->di_nrext64_pad) {
+                               if (!no_modify) {
+                                       do_warn(_("fixing bad nrext64_pad.\n"));
+                                       dino->di_nrext64_pad = 0;
+                                       *dirty = 1;
+                               } else
+                                       do_warn(_("would fix bad nrext64_pad.\n"));
+                       }
+               } else if (dino->di_version >= 3) {
+                       if (dino->di_v3_pad) {
+                               if (!no_modify) {
+                                       do_warn(_("fixing bad v3_pad.\n"));
+                                       dino->di_v3_pad = 0;
+                                       *dirty = 1;
+                               } else
+                                       do_warn(_("would fix bad v3_pad.\n"));
+                       }
+               }
+
                if (!verify_mode && flags2 != be64_to_cpu(dino->di_flags2)) {
                        if (!no_modify) {
                                do_warn(_("fixing bad flags2.\n"));