xfs: check da node magic in _node_lookup_int
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 1 Aug 2018 14:40:48 +0000 (07:40 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 1 Aug 2018 14:42:43 +0000 (07:42 -0700)
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.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
fs/xfs/libxfs/xfs_da_btree.c

index 8ffe17b223dacaaf86af76c5e94d9591ffe056c4..376bee94b5dd0b92ecc94cab2a92247a08adc88e 100644 (file)
@@ -1523,8 +1523,10 @@ xfs_da3_node_lookup_int(
                        break;
                }
 
-               blk->magic = XFS_DA_NODE_MAGIC;
+               if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC)
+                       return -EFSCORRUPTED;
 
+               blk->magic = XFS_DA_NODE_MAGIC;
 
                /*
                 * Search an intermediate node for a match.