Re: [PATCH v2] xfs: check magic numbers in dir3 leaf verifier first

Christoph Hellwig
2013-09-03T07:33:19Z

> @@ -165,6 +165,7 @@ xfs_dir3_leaf_check_int(
> (char *)&ents[hdr->count] > (char *)xfs_dir2_leaf_bests_p(ltp))
> return false;
>
> +
> /* Check hash value order, count stale entries. */

spurious new line..

> if (xfs_sb_version_hascrc(&mp->m_sb)) {
> struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
> + __uint16_t magic3;
>
> + magic3 = (magic == XFS_DIR2_LEAF1_MAGIC) ? XFS_DIR3_LEAF1_MAGIC
> + : XFS_DIR3_LEAFN_MAGIC;
>
> + if (leaf3->info.hdr.magic != cpu_to_be16(magic3))
> + return false;
> if (!uuid_equal(&leaf3->info.uuid, &mp->m_sb.sb_uuid))
> return false;
> if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn)
> return false;
> } else {
> - if (leafhdr.magic != magic)
> + if (leaf->hdr.info.magic != cpu_to_be16(magic))
> return false;
> }

Looks good but I wonder if something like this should be factored into
a separate helper in the long run.

Reviewed-by: Christoph Hellwig <hch@lst.de>