]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
mdrestore: fix restore_v2() superblock length check
authorPavel Reichl <preichl@redhat.com>
Tue, 9 Dec 2025 22:58:52 +0000 (23:58 +0100)
committerAndrey Albershteyn <aalbersh@kernel.org>
Fri, 12 Dec 2025 13:49:28 +0000 (14:49 +0100)
On big-endian architectures (e.g. s390x), restoring a filesystem from a
v2 metadump fails with "Invalid superblock disk address/length". This is
caused by restore_v2() treating a superblock extent length of 1 as an
error, even though a length of 1 is expected because the superblock fits
within a 512-byte sector.

On little-endian systems, the same raw extent length bytes that represent
a value of 1 on big-endian are misinterpreted as 16777216 due to byte
ordering, so the faulty check never triggers there and the bug is hidden.

Fix the issue by using an endian-correct comparison of xme_len so that
the superblock extent length is validated properly and consistently on
all architectures.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chandan Babu R <chandanbabu@kernel.org>
mdrestore/xfs_mdrestore.c

index f10c4befb2fc282dd998722584c37f314c83bb90..b6e8a6196a795a416a5053bc2840214d5aa15fe6 100644 (file)
@@ -437,7 +437,7 @@ restore_v2(
        if (fread(&xme, sizeof(xme), 1, md_fp) != 1)
                fatal("error reading from metadump file\n");
 
-       if (xme.xme_addr != 0 || xme.xme_len == 1 ||
+       if (xme.xme_addr != 0 || be32_to_cpu(xme.xme_len) != 1 ||
            (be64_to_cpu(xme.xme_addr) & XME_ADDR_DEVICE_MASK) !=
                        XME_ADDR_DATA_DEVICE)
                fatal("Invalid superblock disk address/length\n");