* [PATCH v2] xfs: sanitize da node pad field on write
@ 2026-04-23 8:18 Yuto Ohnuki
2026-05-11 11:09 ` Carlos Maiolino
0 siblings, 1 reply; 2+ messages in thread
From: Yuto Ohnuki @ 2026-04-23 8:18 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Darrick J . Wong, Dave Chinner, linux-xfs, linux-kernel,
Yuto Ohnuki
The DA node block header (xfs_da3_node_hdr) contains a __pad32 field
that should always be zero. Prior to commit a45086e27dfa21 ("xfs:
validate metadata LSNs against log on v5 superblocks"),
xfs_da3_node_create() did not zero the full header, so __pad32 could
contain stale data on older filesystems.
Clear this field in the write verifier to ensure it is corrected
whenever the block is next written to disk.
Suggested-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com>
---
Changes in v2:
- Added comments explaining why __pad32 is cleared unconditionally.
- Link to v1: https://lore.kernel.org/all/20260421054311.25301-2-ytohnuki@amazon.com/
---
fs/xfs/libxfs/xfs_da_btree.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index ad801b7bd2dd..4edbf4bb5c7f 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -318,6 +318,12 @@ xfs_da3_node_write_verify(
if (bip)
hdr3->info.lsn = cpu_to_be64(bip->bli_item.li_lsn);
+ /*
+ * Old kernels may not have zeroed the padding field in the header,
+ * so clear it unconditionally to sanitize stale data on disk.
+ */
+ hdr3->__pad32 = 0;
+
xfs_buf_update_cksum(bp, XFS_DA3_NODE_CRC_OFF);
}
--
2.50.1
Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284
Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] xfs: sanitize da node pad field on write
2026-04-23 8:18 [PATCH v2] xfs: sanitize da node pad field on write Yuto Ohnuki
@ 2026-05-11 11:09 ` Carlos Maiolino
0 siblings, 0 replies; 2+ messages in thread
From: Carlos Maiolino @ 2026-05-11 11:09 UTC (permalink / raw)
To: Yuto Ohnuki; +Cc: Darrick J . Wong, Dave Chinner, linux-xfs, linux-kernel
On Thu, Apr 23, 2026 at 09:18:44AM +0100, Yuto Ohnuki wrote:
> The DA node block header (xfs_da3_node_hdr) contains a __pad32 field
> that should always be zero. Prior to commit a45086e27dfa21 ("xfs:
> validate metadata LSNs against log on v5 superblocks"),
> xfs_da3_node_create() did not zero the full header, so __pad32 could
> contain stale data on older filesystems.
>
> Clear this field in the write verifier to ensure it is corrected
> whenever the block is next written to disk.
>
> Suggested-by: "Darrick J. Wong" <djwong@kernel.org>
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com>
> ---
> Changes in v2:
> - Added comments explaining why __pad32 is cleared unconditionally.
> - Link to v1: https://lore.kernel.org/all/20260421054311.25301-2-ytohnuki@amazon.com/
> ---
> fs/xfs/libxfs/xfs_da_btree.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index ad801b7bd2dd..4edbf4bb5c7f 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -318,6 +318,12 @@ xfs_da3_node_write_verify(
> if (bip)
> hdr3->info.lsn = cpu_to_be64(bip->bli_item.li_lsn);
>
> + /*
> + * Old kernels may not have zeroed the padding field in the header,
> + * so clear it unconditionally to sanitize stale data on disk.
> + */
> + hdr3->__pad32 = 0;
> +
> xfs_buf_update_cksum(bp, XFS_DA3_NODE_CRC_OFF);
> }
>
Looks good.
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> --
> 2.50.1
>
>
>
>
> Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284
>
> Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-11 11:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 8:18 [PATCH v2] xfs: sanitize da node pad field on write Yuto Ohnuki
2026-05-11 11:09 ` Carlos Maiolino
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.