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 2AA671A2392 for ; Thu, 2 Apr 2026 08:32:20 +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=1775118741; cv=none; b=hGb1okOaodn1qoIhLhFjof1iPAi6q7UGJmuPmH98LRPtoxYjpygPuiCz4kZ8I/aS0MQIUY1/5MuYcETrguNujSB5q/kFLkPUFIlED3otecOyknyGaIla/6D3CuJwI4y4pZ2MMk7LqYGWZDnGuIVgSi+YzphXRgkVlU8EOjw6kcI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775118741; c=relaxed/simple; bh=nrb6HIjhgxKYnR0UDduqrNoJQQemyIP66gRJkVAcR9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUc3ykd4vRi4lcxVd2/e5zyQQ2o7zOuVeFAj5hqHH2MdaZF1QkOwwiHW4suPXhytBvsDoyISl+5Se7YKQJTDD0lsfsaOb5srl3bjuLF6vgLQ9OxOn3OX7K5EWekmdNG1UJXJfofI7BXuFuSSTn/0HM0DpAX+X6FztX4jlxEyMYU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Imf6nAnL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Imf6nAnL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B743C116C6; Thu, 2 Apr 2026 08:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775118740; bh=nrb6HIjhgxKYnR0UDduqrNoJQQemyIP66gRJkVAcR9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Imf6nAnL/fwgDskwQL9xldVzL4FwAddpLCpc6zRaFkMjkyjRmN+YxLZtxybcog1TO vTPHrg6QTjix0SyOAb09zxYSGU8BhUdQylp+AuFyryOaDHGkGZn1J9kA3UzqhDsTEJ UWqofLPzF2+CHYMhCO9i27elO7MPsr+L0eUrapBPcfXS/9A6BnktPsTi300kStktW3 c4TNgaZHQ5m3T+GaaPgAP3eC+oWdlyKpAQ0BYitLfUPInSwQ3YlVzX7rPcyf04RZld I0ibapvOYJWPUZ4nW6nkPIZQQc8kg9BKmmuYEN4rUHi3ZHs1vf4V8ZV+E4xQ+rx/wl bJ5p7PxHlOU+Q== From: Sasha Levin To: stable@vger.kernel.org Cc: Yuto Ohnuki , syzbot+652af2b3c5569c4ab63c@syzkaller.appspotmail.com, "Darrick J. Wong" , Carlos Maiolino , Sasha Levin Subject: [PATCH 5.10.y] xfs: stop reclaim before pushing AIL during unmount Date: Thu, 2 Apr 2026 04:32:18 -0400 Message-ID: <20260402083218.458355-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026033039-geranium-flame-8f03@gregkh> References: <2026033039-geranium-flame-8f03@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yuto Ohnuki [ Upstream commit 4f24a767e3d64a5f58c595b5c29b6063a201f1e3 ] 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 [ dropped xfs_inodegc_stop() call ] Signed-off-by: Sasha Levin --- fs/xfs/xfs_mount.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 402cf828cc919..c408dded40dc2 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -652,8 +652,9 @@ xfs_check_summary_counts( * 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( @@ -665,8 +666,8 @@ xfs_unmount_flush_inodes( mp->m_flags |= XFS_MOUNT_UNMOUNTING; - xfs_ail_push_all_sync(mp->m_ail); cancel_delayed_work_sync(&mp->m_reclaim_work); + xfs_ail_push_all_sync(mp->m_ail); xfs_reclaim_inodes(mp); xfs_health_unmount(mp); } -- 2.53.0