Skip to content

Commit 376b913

Browse files
hcleeSteve French
authored andcommitted
ksmbd: fix outstanding credits related bugs
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>
1 parent 5366afc commit 376b913

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

fs/ksmbd/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void)
6262
atomic_set(&conn->req_running, 0);
6363
atomic_set(&conn->r_count, 0);
6464
conn->total_credits = 1;
65-
conn->outstanding_credits = 1;
65+
conn->outstanding_credits = 0;
6666

6767
init_waitqueue_head(&conn->req_running_q);
6868
INIT_LIST_HEAD(&conn->conns_list);

fs/ksmbd/smb2misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static int smb2_validate_credit_charge(struct ksmbd_conn *conn,
338338
ret = 1;
339339
}
340340

341-
if ((u64)conn->outstanding_credits + credit_charge > conn->vals->max_credits) {
341+
if ((u64)conn->outstanding_credits + credit_charge > conn->total_credits) {
342342
ksmbd_debug(SMB, "Limits exceeding the maximum allowable outstanding requests, given : %u, pending : %u\n",
343343
credit_charge, conn->outstanding_credits);
344344
ret = 1;

fs/ksmbd/smb_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ int ksmbd_verify_smb_message(struct ksmbd_work *work)
140140

141141
hdr = work->request_buf;
142142
if (*(__le32 *)hdr->Protocol == SMB1_PROTO_NUMBER &&
143-
hdr->Command == SMB_COM_NEGOTIATE)
143+
hdr->Command == SMB_COM_NEGOTIATE) {
144+
work->conn->outstanding_credits++;
144145
return 0;
146+
}
145147

146148
return -EINVAL;
147149
}

0 commit comments

Comments
 (0)