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 C9E3B3E4C6C; Tue, 31 Mar 2026 16:55:09 +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=1774976109; cv=none; b=XmkztcExD4nlHe/1KjuQy3AkoCjb4NOIxyywZTnoDMvBjUwklz9PkUQyWyo3XXWIm2yqyY23G698Wsczm/WXEdvHtzDiLaaFR/kRysGU/UPaiHn5mQoOgc+1ceonlGirzUo25AFLk5MyoPo4VPiTYGEDdhMVCnJa8zKXQ6Riy1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976109; c=relaxed/simple; bh=WLyokls13gb2WA2QiyERNQs3NsCmMT/luNDv73BhrfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6kYTYwkaShOeTGJx0bz9v9B4Il0wxZAAhNk8WGsFP7Zar0eT5a7plOt/DchCevmQXrGWAsYjm3xFse8CUzlJks/uW8P4BPr6ULzh+YIeEsQc76IWdfH69ufjU4ZXLKL9FhEX7q5l6pEM712SConNuBzRYbg1IyylD4bgpv1N6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Aybh0c3l; 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="Aybh0c3l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20EADC19423; Tue, 31 Mar 2026 16:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774976109; bh=WLyokls13gb2WA2QiyERNQs3NsCmMT/luNDv73BhrfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aybh0c3l67moasaVz5SdGGtVCoqhDtPMuwKKWcZEYH+hTHHWin8jivbCxMlD2Glk0 FsfiVjSwrnYMO1VegQyXhjxh3YsqORBZJNc3sJrE8SWXCAHqcMwo8svU5AHDsJ8hkh ZKVbFWoUiEXFsIsfdS3hcuBOh6yUy0ukFYnbXnik= 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.12 177/244] xfs: stop reclaim before pushing AIL during unmount Date: Tue, 31 Mar 2026 18:22:07 +0200 Message-ID: <20260331161748.292931150@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161741.651718120@linuxfoundation.org> References: <20260331161741.651718120@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.12-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 @@ -588,8 +588,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( @@ -601,9 +602,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); }