Skip to content

Commit

Permalink
ksmbd: conn lock to serialize smb2 negotiate
Browse files Browse the repository at this point in the history
If client send parallel smb2 negotiate request on same connection,
ksmbd_conn can be racy. smb2 negotiate handling that are not
performance-related can be serialized with conn lock.

Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Dec 9, 2024
1 parent 08fd7f5 commit dd585a9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)
return rc;
}

ksmbd_conn_lock(conn);
smb2_buf_len = get_rfc1002_len(work->request_buf);
smb2_neg_size = offsetof(struct smb2_negotiate_req, Dialects);
if (smb2_neg_size > smb2_buf_len) {
Expand Down Expand Up @@ -1261,6 +1262,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)
ksmbd_conn_set_need_negotiate(conn);

err_out:
ksmbd_conn_unlock(conn);
if (rc)
rsp->hdr.Status = STATUS_INSUFFICIENT_RESOURCES;

Expand Down

0 comments on commit dd585a9

Please sign in to comment.