Skip to content

Commit 9bbb19d

Browse files
V4belsmfrench
authored andcommitted
ksmbd: do not expire session on binding failure
When a multichannel session binding request fails (e.g. wrong password), the error path unconditionally sets sess->state = SMB2_SESSION_EXPIRED. However, during binding, sess points to the target session looked up via ksmbd_session_lookup_slowpath() -- which belongs to another connection's user. This allows a remote attacker to invalidate any active session by simply sending a binding request with a wrong password (DoS). Fix this by skipping session expiration when the failed request was a binding attempt, since the session does not belong to the current connection. The reference taken by ksmbd_session_lookup_slowpath() is still correctly released via ksmbd_user_session_put(). Cc: [email protected] Signed-off-by: Hyunwoo Kim <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent c369299 commit 9bbb19d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,14 @@ int smb2_sess_setup(struct ksmbd_work *work)
19391939
if (sess->user && sess->user->flags & KSMBD_USER_FLAG_DELAY_SESSION)
19401940
try_delay = true;
19411941

1942-
sess->last_active = jiffies;
1943-
sess->state = SMB2_SESSION_EXPIRED;
1942+
/*
1943+
* For binding requests, session belongs to another
1944+
* connection. Do not expire it.
1945+
*/
1946+
if (!(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
1947+
sess->last_active = jiffies;
1948+
sess->state = SMB2_SESSION_EXPIRED;
1949+
}
19441950
ksmbd_user_session_put(sess);
19451951
work->sess = NULL;
19461952
if (try_delay) {

0 commit comments

Comments
 (0)