Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: validate ag btree levels using the precomputed values

Use the AG btree height limits that we precomputed into the xfs_mount to
validate the AG headers instead of using XFS_BTREE_MAXLEVELS.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>

+7 -7
+4 -4
fs/xfs/libxfs/xfs_alloc.c
··· 2906 2906 2907 2907 if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) < 1 || 2908 2908 be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) < 1 || 2909 - be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) > XFS_BTREE_MAXLEVELS || 2910 - be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > XFS_BTREE_MAXLEVELS) 2909 + be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) > mp->m_ag_maxlevels || 2910 + be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > mp->m_ag_maxlevels) 2911 2911 return __this_address; 2912 2912 2913 2913 if (xfs_sb_version_hasrmapbt(&mp->m_sb) && 2914 2914 (be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) < 1 || 2915 - be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > XFS_BTREE_MAXLEVELS)) 2915 + be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > mp->m_rmap_maxlevels)) 2916 2916 return __this_address; 2917 2917 2918 2918 if (xfs_sb_version_hasrmapbt(&mp->m_sb) && ··· 2939 2939 2940 2940 if (xfs_sb_version_hasreflink(&mp->m_sb) && 2941 2941 (be32_to_cpu(agf->agf_refcount_level) < 1 || 2942 - be32_to_cpu(agf->agf_refcount_level) > XFS_BTREE_MAXLEVELS)) 2942 + be32_to_cpu(agf->agf_refcount_level) > mp->m_refc_maxlevels)) 2943 2943 return __this_address; 2944 2944 2945 2945 return NULL;
+2 -2
fs/xfs/libxfs/xfs_ialloc.c
··· 2535 2535 return __this_address; 2536 2536 2537 2537 if (be32_to_cpu(agi->agi_level) < 1 || 2538 - be32_to_cpu(agi->agi_level) > XFS_BTREE_MAXLEVELS) 2538 + be32_to_cpu(agi->agi_level) > M_IGEO(mp)->inobt_maxlevels) 2539 2539 return __this_address; 2540 2540 2541 2541 if (xfs_sb_version_hasfinobt(&mp->m_sb) && 2542 2542 (be32_to_cpu(agi->agi_free_level) < 1 || 2543 - be32_to_cpu(agi->agi_free_level) > XFS_BTREE_MAXLEVELS)) 2543 + be32_to_cpu(agi->agi_free_level) > M_IGEO(mp)->inobt_maxlevels)) 2544 2544 return __this_address; 2545 2545 2546 2546 /*
+1 -1
fs/xfs/libxfs/xfs_inode_fork.c
··· 195 195 XFS_BMDR_SPACE_CALC(nrecs) > 196 196 XFS_DFORK_SIZE(dip, mp, whichfork) || 197 197 ifp->if_nextents > ip->i_d.di_nblocks) || 198 - level == 0 || level > XFS_BTREE_MAXLEVELS) { 198 + level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) { 199 199 xfs_warn(mp, "corrupt inode %Lu (btree).", 200 200 (unsigned long long) ip->i_ino); 201 201 xfs_inode_verifier_error(ip, -EFSCORRUPTED,