6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Darrick J. Wong commit 1e7337a3ecebab1bb2ba02187d88b94e5146e4f0 upstream. LOLLM observes that the _ilock_both helper will loop forever trying to double-lock the same inode if mpath->dp == sc->ip. Callers are not supposed to call us with parent == child because that makes no sense. Trigger an assertion, mark the scan incomplete, and return IO error so that this fails noisily. Cc: stable@vger.kernel.org # v6.13 Fixes: b3c03efa5972f0 ("xfs: check metadata directory file path connectivity") 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/metapath.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/xfs/scrub/metapath.c +++ b/fs/xfs/scrub/metapath.c @@ -324,6 +324,13 @@ xchk_metapath( return 0; } + /* Callers should not set the parent to the child. */ + if (mpath->dp == sc->ip) { + ASSERT(mpath->dp != sc->ip); + xchk_set_incomplete(sc); + return -EIO; + } + xchk_trans_alloc_empty(sc); error = xchk_metapath_ilock_both(mpath);