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 7713528AAEB for ; Thu, 19 Mar 2026 15:40:58 +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=1773934858; cv=none; b=DZsxzYgl6FPalCl1HBU3VCx6t9M70YcLxCb6H1I7CRM7jZKeJRvN1BJOue4g5tSorgMPHCZ/VhkwR88279NEtLtlWq13Q/6YxOAXK/YTr+Z+ab4+M+6RkRX2Kfrcm/h7AQuRZn5Om87rdbuWLHPFUgqPVnv6FJyfAY6F0MQ32mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773934858; c=relaxed/simple; bh=4o+vM95WN7YmCbnW6Wnhk4oIAcX9l3sokSJFJIF94Gk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bBj8orVAfyvjLeG/oScQcXJy3qdvHKV1m9D+s49ZvdZfPpaR5qOG+b9cRC06RSzu7TjG7ALBZEytN/hdbcxVjwQTlLslRuqPGeBC1nk7Qvs6ZGOX54+FklANIfKp5WAjkg4k390g+nLo3GiEoEkzF2Pl7tN/FVjgQ47Kd4zeNGg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tDzcu2BF; 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="tDzcu2BF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F38CC19424; Thu, 19 Mar 2026 15:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773934858; bh=4o+vM95WN7YmCbnW6Wnhk4oIAcX9l3sokSJFJIF94Gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tDzcu2BFZ132InoMh8c4NgoVyXH4aQmjYcWRAVtXCpq8Yjv5qkKGNXVx0xx/cccf8 Xm9WCqzOTKoUmQ1BhKV3cj/gqEKOgkhZ0Rlzn+8FudbiYHqMHZsG8qB4/KtuFW3+7P 61zGrqGG4TzNlzktSxYs/J7v6Bup6o0XHIJr+NUhDVokf2fcxmYoI9BzRQiPVjJ3mM 7iqMngFlM4CfK0t1B1IKQEiV+6C5OMbAsiroBYehJBoCnqJyd+qeDwk7kkF1V8ABtI mltERFWs9D6Z5Mvv2eP+33tNrF06tEC2SwPwyIQMjOXud+SEjglH4ezVCo1yxHgl2U bTjwj66qm4Erw== From: Sasha Levin To: stable@vger.kernel.org Cc: Shyam Prasad N , Steve French , Sasha Levin Subject: [PATCH 5.15.y 1/2] cifs: unlock chan_lock before calling cifs_put_tcp_session Date: Thu, 19 Mar 2026 11:40:54 -0400 Message-ID: <20260319154055.2633432-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026031729-brethren-snowshoe-607a@gregkh> References: <2026031729-brethren-snowshoe-607a@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: Shyam Prasad N [ Upstream commit 489f710a738e24d887823a010b8b206b4124e26f ] While removing an smb session, we need to free up the tcp session for each channel for that session. We were doing this with chan_lock held. This results in a cyclic dependency with cifs_tcp_ses_lock. For now, unlock the chan_lock temporarily before calling cifs_put_tcp_session. This should not cause any problem for now, since we do not remove channels anywhere else. And this code segment will not be called by two threads. When we do implement the code for removing channels, we will need to execute proper ref counting here. Signed-off-by: Shyam Prasad N Signed-off-by: Steve French Stable-dep-of: d4c7210d2f3e ("smb: client: fix iface port assignment in parse_server_interfaces") Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 677c757fffffb..40c2034450b40 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1788,13 +1788,9 @@ void cifs_put_smb_ses(struct cifs_ses *ses) int i; for (i = 1; i < chan_count; i++) { - /* - * note: for now, we're okay accessing ses->chans - * without chan_lock. But when chans can go away, we'll - * need to introduce ref counting to make sure that chan - * is not freed from under us. - */ + spin_unlock(&ses->chan_lock); cifs_put_tcp_session(ses->chans[i].server, 0); + spin_lock(&ses->chan_lock); ses->chans[i].server = NULL; } } -- 2.51.0