Skip to content

Commit 1ea0868

Browse files
Darrick J. Wonggregkh
authored andcommitted
xfs: fully check the parent handle when it points to the rootdir
commit ba150ce upstream. LOLLM noticed that the directory tree path checking declares the path to be ok if the inumber in the parent pointer reaches the root directory. Unfortunately, it neglects to check that the generation is correct. Fix that by moving the generation check up. Cc: stable@vger.kernel.org # v6.10 Fixes: 928b721 ("xfs: teach online scrub to find directory tree structure problems") Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Assisted-by: LOLLM # finding obvious bugs Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c9662ff commit 1ea0868

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

fs/xfs/scrub/dirtree.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ xchk_dirpath_step_up(
383383
goto out_scanlock;
384384
}
385385

386+
/* The handle encoded in the parent pointer must match. */
387+
if (VFS_I(dp)->i_generation != be32_to_cpu(dl->pptr_rec.p_gen)) {
388+
trace_xchk_dirpath_badgen(dl->sc, dp, path->path_nr,
389+
path->nr_steps, &dl->xname, &dl->pptr_rec);
390+
error = -EFSCORRUPTED;
391+
goto out_scanlock;
392+
}
393+
386394
/* We've reached the root directory; the path is ok. */
387395
if (parent_ino == dl->root_ino) {
388396
xchk_dirpath_set_outcome(dl, path, XCHK_DIRPATH_OK);
@@ -411,14 +419,6 @@ xchk_dirpath_step_up(
411419
goto out_scanlock;
412420
}
413421

414-
/* The handle encoded in the parent pointer must match. */
415-
if (VFS_I(dp)->i_generation != be32_to_cpu(dl->pptr_rec.p_gen)) {
416-
trace_xchk_dirpath_badgen(dl->sc, dp, path->path_nr,
417-
path->nr_steps, &dl->xname, &dl->pptr_rec);
418-
error = -EFSCORRUPTED;
419-
goto out_scanlock;
420-
}
421-
422422
/* Parent pointer must point up to a directory. */
423423
if (!S_ISDIR(VFS_I(dp)->i_mode)) {
424424
trace_xchk_dirpath_nondir_parent(dl->sc, dp, path->path_nr,

0 commit comments

Comments
 (0)