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 6730C2D7386; Wed, 20 May 2026 18:22:31 +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=1779301353; cv=none; b=fkUXc3t0NC1bELp7JZgBHhKiNk8BvH3wMMG3VV5L22XTuuU57UVfVrPNDWHjz5BrRJ3UUPZZA1dy7xOS3AZ48+LvK0eCF46dVznPprxuyX3SPMaVmxQdf5HHhSnGPBu23wOXDSafghOXEfZffWB2/dlQiB6GsBEfplLgRed/hig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779301353; c=relaxed/simple; bh=8G8d7O6eVS2YPjHP8k6V9mKBoKFtxk+fAkqk3gJ8oCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L/X6ja6oPrPbWZWE/1kKfa0R9i+vwdKJD7uQMNwTDxiR4D8tQEjXcB4UE48Rg1KNhQyTdrbv2A72ZJbQ6GdE4L0Mdg6QoPVr+W/5OVQ9+/50tMZrcmXrwuGp6KOOyoRdCUGQBVhr/aJdgzX61HPPkQjBH1LX/K3Wm5kn1MxnVF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AiSGae2y; 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="AiSGae2y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39C881F00899; Wed, 20 May 2026 18:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779301351; bh=WCpBfdsa0xjIDpoScettrcLwyYiqfS2BXQxKdOji1rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AiSGae2ydnFMdiSNUg7h5ugpaq+cxmMt3K66bCf8aHsw7vOmnK5j39d+XPVN0hpee oKY3+0OK2rsYiAPyry9KcTMuw2FHESl56NMptwgUdSGs6I6jN0hgyvd2ZotnaLfzQV iFvlsgjQ/4086ROeftBZFob1LxQj7eMjY5QrGh+I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hyunwoo Kim , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.12 481/666] ksmbd: scope conn->binding slowpath to bound sessions only Date: Wed, 20 May 2026 18:21:32 +0200 Message-ID: <20260520162121.690897918@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hyunwoo Kim [ Upstream commit b0da97c034b6107d14e537e212d4ce8b22109a58 ] When the binding SESSION_SETUP sets conn->binding = true, the flag stays set after the call so that the global session lookup in ksmbd_session_lookup_all() can find the session, which was not added to conn->sessions. Because the flag is connection-wide, the global lookup path will also resolve any other session by id if asked. Tighten the global lookup so that the returned session must have this connection registered in its channel xarray (sess->ksmbd_chann_list). The channel entry is installed by the existing binding_session path in ntlm_authenticate()/krb5_authenticate() when a SESSION_SETUP completes successfully, so this condition is a strict equivalent of "this connection has been accepted as a channel of this session". Connections that have not bound to a given session cannot reach it via the global table. The existing conn->binding gate for entering the slowpath is preserved so that non-binding connections keep the fast-path-only behavior, and the session->state check is unchanged. Fixes: f5a544e3bab7 ("ksmbd: add support for SMB3 multichannel") Signed-off-by: Hyunwoo Kim Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/server/mgmt/user_session.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/smb/server/mgmt/user_session.c b/fs/smb/server/mgmt/user_session.c index faba7a502c0b7..151248e02e9eb 100644 --- a/fs/smb/server/mgmt/user_session.c +++ b/fs/smb/server/mgmt/user_session.c @@ -328,8 +328,13 @@ struct ksmbd_session *ksmbd_session_lookup_all(struct ksmbd_conn *conn, struct ksmbd_session *sess; sess = ksmbd_session_lookup(conn, id); - if (!sess && conn->binding) + if (!sess && conn->binding) { sess = ksmbd_session_lookup_slowpath(id); + if (sess && !xa_load(&sess->ksmbd_chann_list, (long)conn)) { + ksmbd_user_session_put(sess); + sess = NULL; + } + } if (sess && sess->state != SMB2_SESSION_VALID) { ksmbd_user_session_put(sess); sess = NULL; -- 2.53.0