From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5BF1047799D; Tue, 25 Aug 2026 13:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787664631; cv=none; b=o6n3QTiLOv09AEo/vcNEIPrIg1B5kiog9I+QRlQyEzSp5nI9eQX9sZE/VZbtKHlK++xHoLJxDiZgLHg4m2vyoxP5SwkAFi/YD7DbW+WZLaeJg+gZEedBW0LsEDwnC/Mw+suNRMIFWwcMDw/Eh3GJtKhkuOXIYcOTVnJe95n/y1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787664631; c=relaxed/simple; bh=bZEr/3UukigRp6LGte2Xy2R261VxPjwEh9oiXAx4VMc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tmno5V15/fN/wSBdUrgUmLeiQdex6DkONeZihFO+oZ4+f/v7y99KmsYjRpAwU8XEZJ6TUJI2wFmcDBPv5WDmKbuhDF7eJlSl7jwWccNeX8zkinqIcSh3fYij6nIq7QqYi4S5/1Jwpmv2fGjxa84quPXBiT6Ybwt+w6owiTXFyq8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yq9i84Oc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yq9i84Oc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B13611F000E9; Tue, 25 Aug 2026 13:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787664630; bh=67euuwzP37wrO1e0Z2dtlFbf5rD4jRx6C/YVCVyiB3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yq9i84OcC8WVomx76C3RFQFK+yqsjSXb1IiiASAPBX26pg7BR4cEJRx6SBc7KS6Oh Vd0Co5hfZ+AenD2ih62sHYfPNcB8GB6HEscO6ZzgXmCJIoYOBakGSWiIq8Bmf/bH0N IbPC+4/xRxv3DLH5SvwFhrcFwlsJpbFpeN9Jmi64= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+59178abfeb0ea3f0ab20@syzkaller.appspotmail.com, Christoph Hellwig , Yun Zhou , "Darrick J. Wong" , Carlos Maiolino Subject: [PATCH 7.2 33/82] xfs: restore nofs context unconditionally in xfs_trans_roll Date: Tue, 25 Aug 2026 15:25:20 +0200 Message-ID: <20260825132542.803785573@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825132541.560541185@linuxfoundation.org> References: <20260825132541.560541185@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yun Zhou commit 0241ea5fb0fe86d2a673163b2f5815111aadc7f7 upstream. When __xfs_trans_commit() fails in xfs_trans_roll(), the NOFS context is cleared but only restored in the success path. This leaves the error path without nofs protection, causing a circular lock dependency between xfs_nondir_ilock_class and fs_reclaim: CPU0 CPU1 ---- ---- lock(&xfs_nondir_ilock_class); lock(fs_reclaim); lock(&xfs_nondir_ilock_class); lock(fs_reclaim); Fix this by moving xfs_trans_set_context() before the error check so that nofs context is always restored on the new transaction. Reported-by: syzbot+59178abfeb0ea3f0ab20@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=59178abfeb0ea3f0ab20 Fixes: a1ca658d649a ("xfs: fix incorrect context handling in xfs_trans_roll") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Yun Zhou Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_trans.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1029,6 +1029,15 @@ xfs_trans_roll( * duplicate transaction that gets returned. */ error = __xfs_trans_commit(tp, true); + + tp = *tpp; + /* + * __xfs_trans_commit cleared the NOFS flag by calling into + * xfs_trans_free. Set it again here before doing memory + * allocations. + */ + xfs_trans_set_context(tp); + if (error) return error; @@ -1040,13 +1049,6 @@ xfs_trans_roll( * either nothing be locked across this call, or that anything that is * locked be logged in the prior and the next transactions. */ - tp = *tpp; - /* - * __xfs_trans_commit cleared the NOFS flag by calling into - * xfs_trans_free. Set it again here before doing memory - * allocations. - */ - xfs_trans_set_context(tp); error = xfs_log_regrant(tp->t_mountp, tp->t_ticket); if (error) return error;