]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: check that used blocks are smaller than the write pointer
authorChristoph Hellwig <hch@lst.de>
Wed, 14 Jan 2026 06:53:28 +0000 (07:53 +0100)
committerCarlos Maiolino <cem@kernel.org>
Wed, 21 Jan 2026 11:57:17 +0000 (12:57 +0100)
Any used block must have been written, this reject used blocks > write
pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_zone_alloc.c

index 538236ea246635bf4e6e294050990c05a581096e..d127f122d6cf25922a0b677c085cde879da86af7 100644 (file)
@@ -1033,6 +1033,13 @@ xfs_init_zone(
                return -EFSCORRUPTED;
        }
 
+       if (used > write_pointer) {
+               xfs_warn(mp,
+"zone %u has used counter (0x%x) larger than write pointer (0x%x).",
+                        rtg_rgno(rtg), used, write_pointer);
+               return -EFSCORRUPTED;
+       }
+
        if (write_pointer == 0 && used != 0) {
                xfs_warn(mp, "empty zone %u has non-zero used counter (0x%x).",
                        rtg_rgno(rtg), used);