Skip to content

Commit 974c1c2

Browse files
V4belgregkh
authored andcommitted
ksmbd: scope conn->binding slowpath to bound sessions only
[ Upstream commit b0da97c ] 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: f5a544e ("ksmbd: add support for SMB3 multichannel") Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f31beef commit 974c1c2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/smb/server/mgmt/user_session.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,13 @@ struct ksmbd_session *ksmbd_session_lookup_all(struct ksmbd_conn *conn,
328328
struct ksmbd_session *sess;
329329

330330
sess = ksmbd_session_lookup(conn, id);
331-
if (!sess && conn->binding)
331+
if (!sess && conn->binding) {
332332
sess = ksmbd_session_lookup_slowpath(id);
333+
if (sess && !xa_load(&sess->ksmbd_chann_list, (long)conn)) {
334+
ksmbd_user_session_put(sess);
335+
sess = NULL;
336+
}
337+
}
333338
if (sess && sess->state != SMB2_SESSION_VALID) {
334339
ksmbd_user_session_put(sess);
335340
sess = NULL;

0 commit comments

Comments
 (0)