diff mbox series

[SMB3] fix incorrect number of credits when ioctl MaxOutputResponse > 64K

Message ID CAH2r5muKMaDQmfVEWyuVj798Yc1r1_j6hvRmxQhxZibfQ37VpA@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series [SMB3] fix incorrect number of credits when ioctl MaxOutputResponse > 64K | expand

Commit Message

Steve French June 3, 2020, 6:38 a.m. UTC
We were not checking to see if ioctl requests asked for more than
    64K (ie when CIFSMaxBufSize was > 64K) so when setting larger
    CIFSMaxBufSize then ioctls would fail with invalid parameter errors.
    When requests ask for more than 64K in MaxOutputResponse then we
    need to ask for more than 1 credit.

    Signed-off-by: Steve French <stfrench@microsoft.com>
    CC: Stable <stable@vger.kernel.org>
diff mbox series

Patch

From 8f4201046886f0f7d3f2a78620d0cef0a2deac2b Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Wed, 3 Jun 2020 01:33:58 -0500
Subject: [PATCH] smb3: fix incorrect number of credits when ioctl can request
 > 64K

We were not checking to see if ioctl requests asked for more than
64K (ie when CIFSMaxBufSize was > 64K) so when setting larger
CIFSMaxBufSize then ioctls would fail with invalid parameter errors.
When requests ask for more than 64K then we need to ask for more
than 1 credit.

Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Stable <stable@vger.kernel.org>
---
 fs/cifs/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index af067fd30ddb..ded96b529a4d 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2973,7 +2973,7 @@  SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
 	 * response size smaller.
 	 */
 	req->MaxOutputResponse = cpu_to_le32(max_response_size);
-
+	req->sync_hdr.CreditCharge = cpu_to_le16(DIV_ROUND_UP(max_response_size, SMB2_MAX_BUFFER_SIZE));
 	if (is_fsctl)
 		req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL);
 	else
-- 
2.25.1