summaryrefslogtreecommitdiff
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-11-29 16:33:38 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2020-12-09 09:49:38 -0800
commit7396c7fbe07e3c33b578bd9d36e48d42d2acdeb2 (patch)
tree1fa7eff1e6fd8ef554c09389e16d789201e989ec /fs/xfs
parent3c15df3de0e2bcc4390aa95c60fd12edb7f12bdd (diff)
xfs: improve the code that checks recovered extent-free intent items
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_extfree_item.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index f86c8a7c9c4e..bfdfbd192a38 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -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;