xfs: check da node magic in _node_lookup_int
PATCH 1/1 xfs: check da node magic in _node_lookup_int
From: Darrick J. Wong <[email protected]>
Before we start processing what we /think/ is a da3 node block, actually check the magic to make sure that we're looking at a node block. This way we won't blow the asserts in _node_hdr_from_disk on corrupted metadata.
--- fs/xfs/libxfs/xfs_da_btree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_da_btree.c +4 -1
@@ -1522,8 +1522,11 @@ xfs_da3_node_lookup_int(break ; } - blk->magic =XFS_DA_NODE_MAGIC ; +if (blk->magic !=XFS_DA_NODE_MAGIC && + blk->magic !=XFS_DA3_NODE_MAGIC ) +return -EFSCORRUPTED ; + blk->magic =XFS_DA_NODE_MAGIC ;/* * Search an intermediate node for a match.
Quoted 17 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Before we start processing what we /think/ is a da3 node block, actually check the magic to make sure that we're looking at a node block. This way we won't blow the asserts in
_node_hdr_from_diskon corrupted metadata.Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/xfs/libxfs/xfs_da_btree.c +0
-0
fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_lookup_int( · line 1529
Quoted 9 lines
fs/xfs/libxfs/xfs_da_btree.c +4
-1@@ -1522,8 +1522,11 @@ xfs_da3_node_lookup_int(break ; } - blk->magic =XFS_DA_NODE_MAGIC ; +if (blk->magic !=XFS_DA_NODE_MAGIC && + blk->magic !=XFS_DA3_NODE_MAGIC ) +return -EFSCORRUPTED ; + blk->magic =XFS_DA_NODE_MAGIC ;
Can we please use a temporary variable for the on-disk magic number checks, then? blk->magic isn't supposed to hold the on disk format magic number - it's just an indication of the format the current state block points at - so using it to temporarily store the on disk magic number for checks like this is just wrong....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 26 lines · Dave Chinner
Quoted 25 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Before we start processing what we /think/ is a da3 node block, actually check the magic to make sure that we're looking at a node block. This way we won't blow the asserts in
_node_hdr_from_diskon corrupted metadata.Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_da_btree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/xfs/libxfs/xfs_da_btree.c +3
-1@@ -1522,8 +1522,11 @@ xfs_da3_node_lookup_int(break ; } - blk->magic =XFS_DA_NODE_MAGIC ; +if (blk->magic !=XFS_DA_NODE_MAGIC && + blk->magic !=XFS_DA3_NODE_MAGIC ) +return -EFSCORRUPTED ;
Quoted 7 lines
fs/xfs/libxfs/xfs_da_btree.c xfs_da3_node_lookup_int( · line 1529
Quoted 1 line
fs/xfs/libxfs/xfs_da_btree.c +1
-0+ blk->magic =XFS_DA_NODE_MAGIC ;Can we please use a temporary variable for the on-disk magic number checks, then?
blk->magicisn't supposed to hold the on disk format magic number - it's just an indication of the format the current state block points at - so using it to temporarily store the on disk magic number for checks like this is just wrong....
Ok.
--D
Quoted 10 lines
Cheers,
Dave.
Signature · 6 lines
Dave Chinner [email protected] -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html