Skip to content

Commit 497728e

Browse files
jtlaytonsmfrench
authored andcommitted
cifs: fix bad buffer length check in coalesce_t2
The current check looks to see if the RFC1002 length is larger than CIFSMaxBufSize, and fails if it is. The buffer is actually larger than that by MAX_CIFS_HDR_SIZE. This bug has been around for a long time, but the fact that we used to cap the clients MaxBufferSize at the same level as the server tended to paper over it. Commit c974bef changed that however and caused this bug to bite in more cases. Reported-and-Tested-by: Konstantinos Skarlatos <k.skarlatos@gmail.com> Tested-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com>
1 parent f9fab10 commit 497728e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/cifs/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
282282
byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
283283
byte_count += total_in_buf2;
284284
/* don't allow buffer to overflow */
285-
if (byte_count > CIFSMaxBufSize)
285+
if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)
286286
return -ENOBUFS;
287287
pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);
288288

0 commit comments

Comments
 (0)