]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: check da node magic in _node_lookup_int
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)
Source kernel commit: 56830d6cc114f76f656d5e65ab355b070d5a695e

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_da_btree.c

index cf716574a16082eb9c50f7d8c7c4b98d47f61f43..4fceab8844cd421580e0bdb370eccb79834fb967 100644 (file)
@@ -1518,8 +1518,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.