diff mbox series

[3/6] xfs_repair: detect and fix padding fields that changed with nrext64

Message ID 165644937131.1089996.4905575997482466323.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs: random fixes | expand

Commit Message

Darrick J. Wong June 28, 2022, 8:49 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

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>
---
 repair/dinode.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Dave Chinner June 28, 2022, 10:59 p.m. UTC | #1
On Tue, Jun 28, 2022 at 01:49:31PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> 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>
> ---
>  repair/dinode.c |   20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

Looks good.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
diff mbox series

Patch

diff --git a/repair/dinode.c b/repair/dinode.c
index 547c5833..1c92bfbd 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -2709,6 +2709,26 @@  _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
 			}
 		}
 
+		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"));