6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Darrick J. Wong commit 634b63baf05062988456a0bd5df2696c14ea2949 upstream. LOLLM noticed that xchk_refcountbt_rmap_check (and its rt equivalent) will count any rmap owner towards the shared count. However, the only blocks that can be shared between xfs files are written file data blocks; and the only blocks that can have single-refcount entries are COW staging extents. Fix the checking code. Cc: stable@vger.kernel.org # v4.16 Fixes: dbde19da963706 ("xfs: cross-reference the rmapbt data with the refcountbt") Signed-off-by: Darrick J. Wong Assisted-by: LOLLM # finding obvious bugs Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/scrub/refcount.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/fs/xfs/scrub/refcount.c +++ b/fs/xfs/scrub/refcount.c @@ -129,6 +129,18 @@ xchk_refcountbt_rmap_check( return 0; } + /* + * The refcount btree should only have records for written file data + * blocks or for COW staging blocks. + */ + if ((XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) && + rec->rm_owner != XFS_RMAP_OWN_COW) || + (rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK | + XFS_RMAP_UNWRITTEN))) { + xchk_btree_xref_set_corrupt(refchk->sc, cur, 0); + return 0; + } + if (rec->rm_startblock <= refchk->bno && rm_last >= rc_last) { /* * The rmap overlaps the refcount record, so we can confirm