xfs: sanitize da node pad field on write
PATCH 1/1 xfs: sanitize da node pad field on write
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.
--- fs/xfs/libxfs/xfs_da_btree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/xfs/libxfs/xfs_da_btree.c +2 -0
@@ -318,6 +318,8 @@ xfs_da3_node_write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn); + hdr3->__pad32 =0 ; +xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); }
Signature · 8 lines
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
Quoted 20 lines · Yuto Ohnuki
The DA node block header (
xfs_da3_node_hdr) contains a__pad32field that should always be zero. Prior to commita45086e27dfa21("xfs:
validate metadata LSNs against log on v5 superblocks"),xfs_da3_node_create()did not zero the full header, so__pad32could 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" <[email protected]>Signed-off-by Yuto Ohnuki <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_da_btree.c +0
-0
fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_write_verify( · line 321
Quoted 4 lines
fs/xfs/libxfs/xfs_da_btree.c +1
-0@@ -318,6 +318,8 @@ xfs_da3_node_write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn); + hdr3->__pad32 =0 ;
Looks good to me, thanks for clearing this todo :)
--D
Quoted 17 lines
fs/xfs/libxfs/xfs_da_btree.c +1
-0+xfs_buf_update_cksum (bp,XFS_DA3_NODE_CRC_OFF ); }Signature · 8 lines
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
Quoted 20 lines · Yuto Ohnuki
The DA node block header (
xfs_da3_node_hdr) contains a__pad32field that should always be zero. Prior to commita45086e27dfa21("xfs:
validate metadata LSNs against log on v5 superblocks"),xfs_da3_node_create()did not zero the full header, so__pad32could 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" <[email protected]>Signed-off-by Yuto Ohnuki <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.c | 2 ++ 1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_da_btree.c +0
-0
fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_write_verify( · line 322
Quoted 5 lines
fs/xfs/libxfs/xfs_da_btree.c +2
-0@@ -318,6 +318,8 @@ xfs_da3_node_write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn); + hdr3->__pad32 =0 ; +
Please add a comment explaining why the padding is being written unconditionally here. By itself like this it makes no sense at all.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 10 lines · Dave Chinner
Quoted 10 lines
1 file changed, 2 insertions(+)fs/xfs/libxfs/xfs_da_btree.c +0
-0@@ -318,6 +318,8 @@ xfs_da3_node_write_verify(if (bip) hdr3->info.lsn =cpu_to_be64 (bip->bli_item.li_lsn);
Quoted 10 lines
fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_write_verify( · line 322
Quoted 2 lines
fs/xfs/libxfs/xfs_da_btree.c +2
-0+ hdr3->__pad32 =0 ; +Please add a comment explaining why the padding is being written unconditionally here. By itself like this it makes no sense at all.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Thanks for the advice. I'll add the comment and send as v2.
Yuto Ohnuki
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