From: "Darrick J. Wong" <djwong@kernel.org>
To: Pavel Reichl <preichl@redhat.com>
Cc: linux-xfs@vger.kernel.org, chandanbabu@kernel.org,
sandeen@redhat.com, zlang@redhat.com, aalbersh@redhat.com
Subject: Re: [PATCH 1/1] mdrestore: fix restore_v2() superblock length check
Date: Tue, 9 Dec 2025 12:50:17 -0800 [thread overview]
Message-ID: <20251209205017.GX89472@frogsfrogsfrogs> (raw)
In-Reply-To: <20251209202700.1507550-2-preichl@redhat.com>
On Tue, Dec 09, 2025 at 09:27:00PM +0100, Pavel Reichl wrote:
> 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>
> ---
> mdrestore/xfs_mdrestore.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
> index f10c4bef..71c2bb9a 100644
> --- a/mdrestore/xfs_mdrestore.c
> +++ b/mdrestore/xfs_mdrestore.c
> @@ -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 || cpu_to_be32(xme.xme_len) != 1 ||
xme.xme_len is the ondisk value, so that should be be32_to_cpu().
Otherwise the patch looks ok.
--D
> (be64_to_cpu(xme.xme_addr) & XME_ADDR_DEVICE_MASK) !=
> XME_ADDR_DATA_DEVICE)
> fatal("Invalid superblock disk address/length\n");
> --
> 2.52.0
>
>
next prev parent reply other threads:[~2025-12-09 20:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 20:26 [PATCH 0/1] mdrestore: fix restore_v2() superblock length check Pavel Reichl
2025-12-09 20:27 ` [PATCH 1/1] " Pavel Reichl
2025-12-09 20:50 ` Darrick J. Wong [this message]
2025-12-10 5:28 ` Christoph Hellwig
2025-12-10 6:00 ` Christoph Hellwig
2025-12-10 6:20 ` Darrick J. Wong
2025-12-10 22:53 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251209205017.GX89472@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=chandanbabu@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=preichl@redhat.com \
--cc=sandeen@redhat.com \
--cc=zlang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox