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 987A43546C8; Wed, 20 May 2026 17:45:35 +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=1779299136; cv=none; b=Ny0/7dxPOXZ/vigL9Cm3VxDEa6je5twN2W7dwQpTY2UG7huWYjryY4GU7+llastpbf/kNbkMSafizLOL3Vjsrc0qIqO3ukmLva+4YxGdzOHn5ghs5IhluJABwUM8oGZKn7Vqsx3uFhmPzES4k9IoxIBnA5WjbLtwPdkgiO8sQTo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779299136; c=relaxed/simple; bh=HIoGCQlvS//7PO06AyEVE2704aYoBEzceZwsj+kOvKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rHkdsjGPvMRelBtqYZdoWDRiFfPgP+NinQzMVZRy6WdZVscYSs3nXccQLADeJihDdE3uUvUrHiEEDqRorolju53AvyuVn6fG6/h6HmeNQJBABgOV6/UVvXBrxkbSCHDHN1mCGH4qMcNjIOAwFusr0ULojSY3KRYDjYlyCMR+D5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wediqTDI; 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="wediqTDI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0124F1F000E9; Wed, 20 May 2026 17:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779299135; bh=nXdsbzjajRq4yaxo/Ug9MVo1KpFncGL+DzxmG+sQn5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wediqTDIXkM6Jq1+CGeVIXknXFnL1gpJ+kwu3+/UxG2PNitr4I+etFzocwh+gGb/E uY9PJowlTWw+Oa1L+r7BtxTn3P7jvEMFJ6CL5BvdNRpbFfnVVeUplbhBxxF7I19L90 UnQ8aNqxJZtQakYvJBRvvS6FM8iueHp35cdNZhG0= 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.18 677/957] ksmbd: scope conn->binding slowpath to bound sessions only Date: Wed, 20 May 2026 18:19:20 +0200 Message-ID: <20260520162149.220298721@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@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.18-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 afa0daa3f5d88..5bc2f18d68bbc 100644 --- a/fs/smb/server/mgmt/user_session.c +++ b/fs/smb/server/mgmt/user_session.c @@ -327,8 +327,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