Skip to content

Commit

Permalink
xfs: improve the code that checks recovered extent-free intent items
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Brian Foster <[email protected]>
  • Loading branch information
djwong committed Dec 9, 2020
1 parent 3c15df3 commit 7396c7f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions fs/xfs/xfs_extfree_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7396c7f

Please sign in to comment.