|
@@ -1261,11 +1261,15 @@ xfs_iread_extents(
|
|
|
*/
|
|
|
frp = XFS_BMBT_REC_ADDR(mp, block, 1);
|
|
|
for (j = 0; j < num_recs; j++, frp++, i++) {
|
|
|
+ xfs_failaddr_t fa;
|
|
|
+
|
|
|
xfs_bmbt_disk_get_all(frp, &new);
|
|
|
- if (!xfs_bmbt_validate_extent(mp, whichfork, &new)) {
|
|
|
- XFS_ERROR_REPORT("xfs_bmap_read_extents(2)",
|
|
|
- XFS_ERRLEVEL_LOW, mp);
|
|
|
+ fa = xfs_bmap_validate_extent(ip, whichfork, &new);
|
|
|
+ if (fa) {
|
|
|
error = -EFSCORRUPTED;
|
|
|
+ xfs_inode_verifier_error(ip, error,
|
|
|
+ "xfs_iread_extents(2)",
|
|
|
+ frp, sizeof(*frp), fa);
|
|
|
goto out_brelse;
|
|
|
}
|
|
|
xfs_iext_insert(ip, &icur, &new, state);
|
|
@@ -6154,3 +6158,39 @@ xfs_bmap_finish_one(
|
|
|
|
|
|
return error;
|
|
|
}
|
|
|
+
|
|
|
+/* Check that an inode's extent does not have invalid flags or bad ranges. */
|
|
|
+xfs_failaddr_t
|
|
|
+xfs_bmap_validate_extent(
|
|
|
+ struct xfs_inode *ip,
|
|
|
+ int whichfork,
|
|
|
+ struct xfs_bmbt_irec *irec)
|
|
|
+{
|
|
|
+ struct xfs_mount *mp = ip->i_mount;
|
|
|
+ xfs_fsblock_t endfsb;
|
|
|
+ bool isrt;
|
|
|
+
|
|
|
+ isrt = XFS_IS_REALTIME_INODE(ip);
|
|
|
+ endfsb = irec->br_startblock + irec->br_blockcount - 1;
|
|
|
+ if (isrt) {
|
|
|
+ if (!xfs_verify_rtbno(mp, irec->br_startblock))
|
|
|
+ return __this_address;
|
|
|
+ if (!xfs_verify_rtbno(mp, endfsb))
|
|
|
+ return __this_address;
|
|
|
+ } else {
|
|
|
+ if (!xfs_verify_fsbno(mp, irec->br_startblock))
|
|
|
+ return __this_address;
|
|
|
+ if (!xfs_verify_fsbno(mp, endfsb))
|
|
|
+ return __this_address;
|
|
|
+ if (XFS_FSB_TO_AGNO(mp, irec->br_startblock) !=
|
|
|
+ XFS_FSB_TO_AGNO(mp, endfsb))
|
|
|
+ return __this_address;
|
|
|
+ }
|
|
|
+ if (irec->br_state != XFS_EXT_NORM) {
|
|
|
+ if (whichfork != XFS_DATA_FORK)
|
|
|
+ return __this_address;
|
|
|
+ if (!xfs_sb_version_hasextflgbit(&mp->m_sb))
|
|
|
+ return __this_address;
|
|
|
+ }
|
|
|
+ return NULL;
|
|
|
+}
|