xfs: check owner of dir3 free blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 11 Mar 2020 17:37:56 +0000 (10:37 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 12 Mar 2020 14:58:12 +0000 (07:58 -0700)
Check the owner field of dir3 free block headers and reject the metadata
if there's something wrong with it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/libxfs/xfs_dir2_node.c

index bbd478e..6ac4aad 100644 (file)
@@ -194,6 +194,8 @@ xfs_dir3_free_header_check(
                        return __this_address;
                if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
                        return __this_address;
+               if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
+                       return __this_address;
        } else {
                struct xfs_dir2_free_hdr *hdr = bp->b_addr;