summaryrefslogtreecommitdiff
path: root/fs/ksmbd/smb2misc.c
diff options
context:
space:
mode:
authorNamjae Jeon <linkinjeon@kernel.org>2021-12-31 09:26:25 +0900
committerSteve French <stfrench@microsoft.com>2022-01-10 12:44:19 -0600
commitb589f5db6d4af8f14d70e31e1276b4c017668a26 (patch)
treed5d2850a5a54c553245e40435576b89da8d19008 /fs/ksmbd/smb2misc.c
parent914d7e5709ac59ded70bea7956d408fe2acd7c3c (diff)
ksmbd: limits exceeding the maximum allowable outstanding requests
If the client ignores the CreditResponse received from the server and continues to send the request, ksmbd limits the requests if it exceeds smb2 max credits. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/smb2misc.c')
-rw-r--r--fs/ksmbd/smb2misc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/ksmbd/smb2misc.c b/fs/ksmbd/smb2misc.c
index fedcb753c7af..4a9460153b59 100644
--- a/fs/ksmbd/smb2misc.c
+++ b/fs/ksmbd/smb2misc.c
@@ -337,7 +337,16 @@ static int smb2_validate_credit_charge(struct ksmbd_conn *conn,
credit_charge, conn->total_credits);
ret = 1;
}
+
+ if ((u64)conn->outstanding_credits + credit_charge > conn->vals->max_credits) {
+ ksmbd_debug(SMB, "Limits exceeding the maximum allowable outstanding requests, given : %u, pending : %u\n",
+ credit_charge, conn->outstanding_credits);
+ ret = 1;
+ } else
+ conn->outstanding_credits += credit_charge;
+
spin_unlock(&conn->credits_lock);
+
return ret;
}