From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A31E3081D6; Tue, 31 Mar 2026 17:07:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976836; cv=none; b=CDa2PR3r/MEYgi+IboaHf0x/hgC0CTM9HqbEBOa6AZ98+YJqLtZRbCYalqUSNhMQBB8sU4l6fayNl9j/V4uvs5Ci5Gq7lRblYZcvlPn2cSQSwpPqUgseh/+XwxRDVrpAPDdlTN2UGeVOKXD7fE9NeB7YVAWKwgoRw0I61bGFJhI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976836; c=relaxed/simple; bh=S4PMCqFc9U9dsQDCLg+XtlM3JXLElOICe4kdwF+PbQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rb4tETdXBKnpLWy0nOqJqUWkUI2jSU7rcT5qyD21RgNGWLbO68ehhQx0fFJNJNy3fkq46c5teGWOhFqO0fhkHMmUWT5ErcKp/B1S2n5oOh9f3eo9ILHwS7yp6WdJXSIPQGdntH1olCaKC+swK5xignNItv/J59dELi3knwWw9Kg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bdHryI4f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bdHryI4f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4C5FC19423; Tue, 31 Mar 2026 17:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774976836; bh=S4PMCqFc9U9dsQDCLg+XtlM3JXLElOICe4kdwF+PbQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdHryI4f7RjlON7Mllfzvny4j8hyf6ZhXR2DJmluOLHyHkS32UA06LN2mCyGuGPaw wT2GqAQrNHZ050lqBN4raCf3zFkAtJup9SPqgQhmrA1aBQA91yn7DeYe21SdSkdVoQ tNkLQorePqlsliYdQg0QxxG6ch7lUGKHZYrjfg4E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+652af2b3c5569c4ab63c@syzkaller.appspotmail.com, Yuto Ohnuki , "Darrick J. Wong" , Carlos Maiolino Subject: [PATCH 6.18 247/309] xfs: stop reclaim before pushing AIL during unmount Date: Tue, 31 Mar 2026 18:22:30 +0200 Message-ID: <20260331161802.662521736@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161753.468533260@linuxfoundation.org> References: <20260331161753.468533260@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuto Ohnuki commit 4f24a767e3d64a5f58c595b5c29b6063a201f1e3 upstream. The unmount sequence in xfs_unmount_flush_inodes() pushed the AIL while background reclaim and inodegc are still running. This is broken independently of any use-after-free issues - background reclaim and inodegc should not be running while the AIL is being pushed during unmount, as inodegc can dirty and insert inodes into the AIL during the flush, and background reclaim can race to abort and free dirty inodes. Reorder xfs_unmount_flush_inodes() to stop inodegc and cancel background reclaim before pushing the AIL. Stop inodegc before cancelling m_reclaim_work because the inodegc worker can re-queue m_reclaim_work via xfs_inodegc_set_reclaimable. Reported-by: syzbot+652af2b3c5569c4ab63c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=652af2b3c5569c4ab63c Fixes: 90c60e164012 ("xfs: xfs_iflush() is no longer necessary") Cc: stable@vger.kernel.org # v5.9 Signed-off-by: Yuto Ohnuki Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_mount.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -607,8 +607,9 @@ xfs_unmount_check( * have been retrying in the background. This will prevent never-ending * retries in AIL pushing from hanging the unmount. * - * Finally, we can push the AIL to clean all the remaining dirty objects, then - * reclaim the remaining inodes that are still in memory at this point in time. + * Stop inodegc and background reclaim before pushing the AIL so that they + * are not running while the AIL is being flushed. Then push the AIL to + * clean all the remaining dirty objects and reclaim the remaining inodes. */ static void xfs_unmount_flush_inodes( @@ -620,9 +621,9 @@ xfs_unmount_flush_inodes( xfs_set_unmounting(mp); - xfs_ail_push_all_sync(mp->m_ail); xfs_inodegc_stop(mp); cancel_delayed_work_sync(&mp->m_reclaim_work); + xfs_ail_push_all_sync(mp->m_ail); xfs_reclaim_inodes(mp); xfs_health_unmount(mp); }