Message ID | 160679391475.447963.3291546751575520166.stgit@magnolia (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | xfs: strengthen log intent validation | expand |
On Mon, Nov 30, 2020 at 07:38:34PM -0800, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > The bmap, rmap, and refcount log intent items were added to support the > rmap and reflink features. Because these features come with changes to > the ondisk format, the log items aren't tied to a log incompat flags. > > However, the log recovery routines don't actually check for those > feature flags. The kernel has no business replayng an intent item for a > feature that isn't enabled, so check that as part of recovered log item > validation. (Note that kernels pre-dating rmap and reflink will fail > the mount on the unknown log item type code.) > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 19f89a6b65a1..f36005c999b2 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -426,6 +426,10 @@ xfs_bui_validate( struct xfs_map_extent *bmap; xfs_fsblock_t end; + if (!xfs_sb_version_hasrmapbt(&mp->m_sb) && + !xfs_sb_version_hasreflink(&mp->m_sb)) + return false; + /* Only one mapping operation per BUI... */ if (buip->bui_format.bui_nextents != XFS_BUI_MAX_FAST_EXTENTS) return false; diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 20e5c22bb754..2017108b37a1 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -425,6 +425,9 @@ xfs_cui_validate_phys( { xfs_fsblock_t end; + if (!xfs_sb_version_hasreflink(&mp->m_sb)) + return false; + if (refc->pe_flags & ~XFS_REFCOUNT_EXTENT_FLAGS) return false; diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 2779cbee8fa8..13871882ffb6 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -468,6 +468,9 @@ xfs_rui_validate_map( { xfs_fsblock_t end; + if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) + return false; + if (rmap->me_flags & ~XFS_RMAP_EXTENT_FLAGS) return false;