]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
xfs: mark dir corrupt when lookup-by-hash fails
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 11 Mar 2020 17:37:57 +0000 (10:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:14:37 +0000 (13:14 +0200)
[ Upstream commit 2e107cf869eecc770e3f630060bb4e5f547d0fd8 ]

In xchk_dir_actor, we attempt to validate the directory hash structures
by performing a directory entry lookup by (hashed) name.  If the lookup
returns ENOENT, that means that the hash information is corrupt.  The
_process_error functions don't catch this, so we have to add that
explicitly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/xfs/scrub/dir.c

index cd3e4d768a18ce2d6466c973dfe891174cc523cf..33dfcba72c7a055f134dbb7010ee4bc584be7613 100644 (file)
@@ -156,6 +156,9 @@ xchk_dir_actor(
        xname.type = XFS_DIR3_FT_UNKNOWN;
 
        error = xfs_dir_lookup(sdc->sc->tp, ip, &xname, &lookup_ino, NULL);
+       /* ENOENT means the hash lookup failed and the dir is corrupt */
+       if (error == -ENOENT)
+               error = -EFSCORRUPTED;
        if (!xchk_fblock_process_error(sdc->sc, XFS_DATA_FORK, offset,
                        &error))
                goto out;