Skip to content

Commit ebf5744

Browse files
namjaejeonsmfrench
authored andcommitted
smb3: add indatalen that can be a non-zero value to calculation of credit charge in smb2 ioctl
Some of tests in xfstests failed with cifsd kernel server since commit e80ddeb. cifsd kernel server validates credit charge from client by calculating it base on max((InputCount + OutputCount) and (MaxInputResponse + MaxOutputResponse)) according to specification. MS-SMB2 specification describe credit charge calculation of smb2 ioctl : If Connection.SupportsMultiCredit is TRUE, the server MUST validate CreditCharge based on the maximum of (InputCount + OutputCount) and (MaxInputResponse + MaxOutputResponse), as specified in section 3.3.5.2.5. If the validation fails, it MUST fail the IOCTL request with STATUS_INVALID_PARAMETER. This patch add indatalen that can be a non-zero value to calculation of credit charge in SMB2_ioctl_init(). Fixes: e80ddeb ("smb3: fix incorrect number of credits when ioctl MaxOutputResponse > 64K") Cc: Stable <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> Cc: Steve French <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 7866c17 commit ebf5744

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/cifs/smb2pdu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2973,7 +2973,9 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
29732973
* response size smaller.
29742974
*/
29752975
req->MaxOutputResponse = cpu_to_le32(max_response_size);
2976-
req->sync_hdr.CreditCharge = cpu_to_le16(DIV_ROUND_UP(max_response_size, SMB2_MAX_BUFFER_SIZE));
2976+
req->sync_hdr.CreditCharge =
2977+
cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size),
2978+
SMB2_MAX_BUFFER_SIZE));
29772979
if (is_fsctl)
29782980
req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL);
29792981
else

0 commit comments

Comments
 (0)