From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57961C4167B for ; Wed, 9 Feb 2022 18:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbiBISfn (ORCPT ); Wed, 9 Feb 2022 13:35:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239549AbiBISfi (ORCPT ); Wed, 9 Feb 2022 13:35:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2988DC05CBA5; Wed, 9 Feb 2022 10:35:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D2613B82378; Wed, 9 Feb 2022 18:35:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A806FC340E7; Wed, 9 Feb 2022 18:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644431738; bh=ThG/+Gd9ta56OPtFM3T/EEq/XFxpoRWYUP0PR2/q2SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gl/n5sARnAEzqop9HB0fBeqOTXvTY2e4PpDMwG1+t2zpOlfGph9mdIvYtyAW7Bf7Z VCHCjUNf6X31s1uqVbHIltQTCiy1ORbsgtrnmm7ZuFlspalJGhdoddYA4i1h0/GCm4 0ZIijgp7pM4NPErxIfznQisYzR9lEbtEpo1ZAF+MP0DUP9py/3CHdVbIzNzrWDuyCf T0jz6UP29QGkyCOZ+0LMz4ZHF3E669K31xaTG97fLOAV3/rt4s97p26UIGGWbpXG9N 024YsZwFrPq9iZUasq8aRcQYgFsPzySH48on0WYGPSJze90wc8s9WOIRE7DXiil4yb LLzS6+rFBU43Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shyam Prasad N , Steve French , Sasha Levin , sfrench@samba.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH AUTOSEL 5.16 19/42] cifs: unlock chan_lock before calling cifs_put_tcp_session Date: Wed, 9 Feb 2022 13:32:51 -0500 Message-Id: <20220209183335.46545-19-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209183335.46545-1-sashal@kernel.org> References: <20220209183335.46545-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 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 1060164b984a7..4c8db1a91e940 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1796,13 +1796,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.34.1