]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
xfs: improve the code that checks recovered extent-free intent items
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 30 Nov 2020 00:33:38 +0000 (16:33 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 9 Dec 2020 17:49:38 +0000 (09:49 -0800)
The code that validates recovered extent-free intent items is kind of a
mess -- it doesn't use the standard xfs type validators, and it doesn't
check for things that it should.  Fix the validator function to use the
standard validation helpers and look for more types of obvious errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/xfs_extfree_item.c

index f86c8a7c9c4ee742125b2d471b24c61cb5a18c48..bfdfbd192a38e6048f444a0dc532e1f8fea8bf94 100644 (file)
@@ -584,14 +584,13 @@ xfs_efi_validate_ext(
        struct xfs_mount                *mp,
        struct xfs_extent               *extp)
 {
-       xfs_fsblock_t                   startblock_fsb;
-
-       startblock_fsb = XFS_BB_TO_FSB(mp,
-                          XFS_FSB_TO_DADDR(mp, extp->ext_start));
-       if (startblock_fsb == 0 ||
-           extp->ext_len == 0 ||
-           startblock_fsb >= mp->m_sb.sb_dblocks ||
-           extp->ext_len >= mp->m_sb.sb_agblocks)
+       if (extp->ext_start + extp->ext_len <= extp->ext_start)
+               return false;
+
+       if (!xfs_verify_fsbno(mp, extp->ext_start))
+               return false;
+
+       if (!xfs_verify_fsbno(mp, extp->ext_start + extp->ext_len - 1))
                return false;
 
        return true;