diff mbox series

[08/10] xfs: improve the code that checks recovered extent-free intent items

Message ID 160679390871.447963.15070829026899571950.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: strengthen log intent validation | expand

Commit Message

Darrick J. Wong Dec. 1, 2020, 3:38 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

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>
---
 fs/xfs/xfs_extfree_item.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Christoph Hellwig Dec. 1, 2020, 10:07 a.m. UTC | #1
Looks good modulo the end nitpick:

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

Patch

diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index b5710b7fc263..b1c004016709 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -584,14 +584,14 @@  xfs_efi_validate_ext(
 	struct xfs_mount		*mp,
 	struct xfs_extent		*extp)
 {
-	xfs_fsblock_t			startblock_fsb;
+	xfs_fsblock_t			end;
 
-	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;
+
+	end = extp->ext_start + extp->ext_len - 1;
+	if (!xfs_verify_fsbno(mp, extp->ext_start) ||
+	    !xfs_verify_fsbno(mp, end))
 		return false;
 
 	return true;