ksmbd: scope conn->binding slowpath to bound sessions only
Subsystems (2)
PATCH 1/1 ksmbd: scope conn->binding slowpath to bound sessions only
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.
--- fs/smb/server/mgmt/user_session.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/smb/server/mgmt/user_session.c +6 -1
@@ -547,8 +547,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 ;
Signature · 1 line
2.43.0
Quoted 16 lines · Hyunwoo Kim
When the binding
SESSION_SETUPsetsconn->binding= true, the flag stays set after the call so that the global session lookup inksmbd_session_lookup_all()can find the session, which was not added toconn->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 existingbinding_sessionpath in ntlm_authenticate()/krb5_authenticate() when aSESSION_SETUPcompletes 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.
Quoted 6 lines
The existing
conn->bindinggate for entering the slowpath is preserved so that non-binding connections keep the fast-path-only behavior, and thesession->statecheck is unchanged.Fixes f5a544e3bab7 ("ksmbd: add support for SMB3 multichannel")Signed-off-by Hyunwoo Kim <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks!