Skip to content

Commit 84c5aa4

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix credit count leakage
This patch fix the failure from smb2.credits.single_req_credits_granted test. When client send 8192 credit request, ksmbd return 8191 credit granted. ksmbd should give maximum possible credits that must be granted within the range of not exceeding the max credit to client. Cc: stable@vger.kernel.org Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent df14afe commit 84c5aa4

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,9 @@ int smb2_set_rsp_credits(struct ksmbd_work *work)
326326
if (hdr->Command == SMB2_NEGOTIATE)
327327
aux_max = 1;
328328
else
329-
aux_max = conn->vals->max_credits - credit_charge;
329+
aux_max = conn->vals->max_credits - conn->total_credits;
330330
credits_granted = min_t(unsigned short, credits_requested, aux_max);
331331

332-
if (conn->vals->max_credits - conn->total_credits < credits_granted)
333-
credits_granted = conn->vals->max_credits -
334-
conn->total_credits;
335-
336332
conn->total_credits += credits_granted;
337333
work->credits_granted += credits_granted;
338334

0 commit comments

Comments
 (0)