From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388744; b=qewiEzC5sUhZQouGE3zuJZ1zahbWnBqVOh/o2aisI5ZvXMycDBRldHaJAF3EBCRDQelg 2+Y6bo8lg3XgI+NueTdHtCpUy0Qz0KBSXs5g8KWppHcKjvs5sD0ZIEhfSFaW1CZVgZZYV x0J5hnYIpk3/fcRyHnyduUigGg1PIxh1H/fiKkO1fRinTX/Mg9017jOAfZNQ5F1nUBnfo Jkagz41mFQjJgMop0EqTxS+mGYQmii48KBtMBuKJnRHAcyfEqG0L7hlDIoAJghKk5g3EB iZf1xwr3iZ4wgm0Tvh7roeOWH/c45YbEVSae0lysD7bpec65TzUMPxxHyE4YLZCAaTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388744; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=DWZqpM/Dso5pk2oRSER15DdCaqUrN4apKGzbKQ+ih74=; b=HXwBMCYCF1DkZ9uY1zVUfv3UEGMci36dbXFBsGEXbGz/CDpA1efefWGjP2DkyGDIM1Rd CwEoJm8dLq2lxPS9VsJZRQZXaw//M4F9R/ctgQSjIKB9UvqtknY7BCZIGVjBcn9xd5Cjb +7586Z1W0CONlcQ2aSeZDvAYjcLlyPRsrcdPGUD7ox0a6siyj4aNBGUZNuJKNoTmVnVk9 TrHCCos7bAp/6OipjAy9YhIaGAIsI3zuaaYPyZM6/S48IIAX11C7YQozSpwpUS0GCfZy+ gfiNxapR2OpIzigPCMdRFMaG7Eq4AuJeq3kUZsaQ/+2rt30aCcY/KutWWeXIbAi8YYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OaUqnlPc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 878EC606A32D; Fri, 4 Dec 2026 12:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OaUqnlPc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97D5B1F000C2; Fri, 4 Dec 2026 12:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388744; bh=DWZqpM/Dso5pk2oRSER15DdCaqUrN4apKGzbKQ+ih74=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OaUqnlPcriTS5LAp+QLLGQB7fvRP2EMv/v+Dj+rIzGmEnSmX1gKQ3B8R7COkoiYAi SDYhHX169XE/J4QJSMWgSUQvtqFdacQn7OXCWDG3DpgIhBVAU2aBSl+vruFJE8aqF9 QthSWWd3vv/xAxHnoh2ffy8hpky4wUuXzxpb/UvY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joseph Qi , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.1 0737/1059] smb: client: skip NULL channel in __cifs_put_smb_ses() Date: Fri, 4 Dec 2026 19:04:28 +0900 Message-ID: <20261204100703.068880595@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joseph Qi [ Upstream commit 8deaf64a59a263161dfc5128f8398fb3dcba4fac ] cifs_chan_skip_or_disable() clears a secondary channel's slot in the session (ses->chans[chan_index].server = NULL) without lowering chan_count when the server stops supporting multichannel. When the session is later released, __cifs_put_smb_ses() walks every slot up to chan_count and calls cifs_put_tcp_session() on it, which dereferences the server pointer immediately, so a slot left NULL by the skip path makes the release crash with a NULL pointer dereference. Clearing a slot without lowering chan_count is older than cifs_chan_skip_or_disable(): cifs_chan_update_iface() could already do the same since commit b54034a73baf9 ("cifs: during reconnect, update interface if necessary"), and the release loop has been unguarded since then. Commit 12d1e301bdfd1 ("cifs: do not let cifs_chan_update_iface deallocate channels") later removed that trigger, but the crash is reachable through it on older kernels. cifs_decrease_secondary_channels() already guards the same put with if (server). Add the same guard to the release loop so a skipped channel slot is left alone. Fixes: b54034a73baf9 ("cifs: during reconnect, update interface if necessary") Cc: stable@vger.kernel.org Signed-off-by: Joseph Qi Signed-off-by: Paulo Alcantara [ sashal: adapted the hunk to this tree's cifs_put_smb_ses() loop, which is nested one level deeper and uses a cached chan_count, so the NULL-check guard sits at different indentation and context. ] Signed-off-by: Sasha Levin --- fs/smb/client/connect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index df8634228cbad..8d2a586f9631c 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -2103,7 +2103,8 @@ void cifs_put_smb_ses(struct cifs_ses *ses) kref_put(&ses->chans[i].iface->refcount, release_iface); ses->chans[i].iface = NULL; } - cifs_put_tcp_session(ses->chans[i].server, 0); + if (ses->chans[i].server) + cifs_put_tcp_session(ses->chans[i].server, 0); ses->chans[i].server = NULL; } } -- 2.53.0