Skip to content

Commit

Permalink
ksmbd: fix outstanding credits related bugs
Browse files Browse the repository at this point in the history
outstanding credits must be initialized to 0,
because it means the sum of credits consumed by
in-flight requests.
And outstanding credits must be compared with
total credits in smb2_validate_credit_charge(),
because total credits are the sum of credits
granted by ksmbd.

This patch fix the following error,
while frametest with Windows clients:

Limits exceeding the maximum allowable outstanding requests,
given : 128, pending : 8065

Fixes: b589f5d ("ksmbd: limits exceeding the maximum allowable outstanding requests")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Reported-by: Yufan Chen <wiz.chen@gmail.com>
Tested-by: Yufan Chen <wiz.chen@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Hyunchul Lee authored and Steve French committed May 21, 2022
1 parent 5366afc commit 376b913
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/ksmbd/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void)
atomic_set(&conn->req_running, 0);
atomic_set(&conn->r_count, 0);
conn->total_credits = 1;
conn->outstanding_credits = 1;
conn->outstanding_credits = 0;

init_waitqueue_head(&conn->req_running_q);
INIT_LIST_HEAD(&conn->conns_list);
Expand Down
2 changes: 1 addition & 1 deletion fs/ksmbd/smb2misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int smb2_validate_credit_charge(struct ksmbd_conn *conn,
ret = 1;
}

if ((u64)conn->outstanding_credits + credit_charge > conn->vals->max_credits) {
if ((u64)conn->outstanding_credits + credit_charge > conn->total_credits) {
ksmbd_debug(SMB, "Limits exceeding the maximum allowable outstanding requests, given : %u, pending : %u\n",
credit_charge, conn->outstanding_credits);
ret = 1;
Expand Down
4 changes: 3 additions & 1 deletion fs/ksmbd/smb_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ int ksmbd_verify_smb_message(struct ksmbd_work *work)

hdr = work->request_buf;
if (*(__le32 *)hdr->Protocol == SMB1_PROTO_NUMBER &&
hdr->Command == SMB_COM_NEGOTIATE)
hdr->Command == SMB_COM_NEGOTIATE) {
work->conn->outstanding_credits++;
return 0;
}

return -EINVAL;
}
Expand Down

0 comments on commit 376b913

Please sign in to comment.