xfs: rtbitmap scrubber should check inode size
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 2 Jul 2020 15:42:13 +0000 (08:42 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 7 Jul 2020 14:15:09 +0000 (07:15 -0700)
Make sure the rtbitmap is large enough to store the entire bitmap.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
fs/xfs/scrub/rtbitmap.c

index c777c98..76e4ffe 100644 (file)
@@ -101,6 +101,13 @@ xchk_rtbitmap(
 {
        int                     error;
 
+       /* Is the size of the rtbitmap correct? */
+       if (sc->mp->m_rbmip->i_d.di_size !=
+           XFS_FSB_TO_B(sc->mp, sc->mp->m_sb.sb_rbmblocks)) {
+               xchk_ino_set_corrupt(sc, sc->mp->m_rbmip->i_ino);
+               return 0;
+       }
+
        /* Invoke the fork scrubber. */
        error = xchk_metadata_inode_forks(sc);
        if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))