Skip to content

Commit fb53347

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: do not allow the actual frame length to be smaller than the rfc1002 length
ksmbd allowed the actual frame length to be smaller than the rfc1002 length. If allowed, it is possible to allocates a large amount of memory that can be limited by credit management and can eventually cause memory exhaustion problem. This patch do not allow it except SMB2 Negotiate request which will be validated when message handling proceeds. Also, Allow a message that padded to 8byte boundary. Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3") Cc: [email protected] Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 8f8c43b commit fb53347

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

fs/ksmbd/smb2misc.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,19 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
408408
goto validate_credit;
409409

410410
/*
411-
* windows client also pad up to 8 bytes when compounding.
412-
* If pad is longer than eight bytes, log the server behavior
413-
* (once), since may indicate a problem but allow it and
414-
* continue since the frame is parseable.
411+
* SMB2 NEGOTIATE request will be validated when message
412+
* handling proceeds.
415413
*/
416-
if (clc_len < len) {
417-
ksmbd_debug(SMB,
418-
"cli req padded more than expected. Length %d not %d for cmd:%d mid:%llu\n",
419-
len, clc_len, command,
420-
le64_to_cpu(hdr->MessageId));
414+
if (command == SMB2_NEGOTIATE_HE)
415+
goto validate_credit;
416+
417+
/*
418+
* Allow a message that padded to 8byte boundary.
419+
*/
420+
if (clc_len < len && (len - clc_len) < 8)
421421
goto validate_credit;
422-
}
423422

424-
ksmbd_debug(SMB,
423+
pr_err_ratelimited(
425424
"cli req too short, len %d not %d. cmd:%d mid:%llu\n",
426425
len, clc_len, command,
427426
le64_to_cpu(hdr->MessageId));

0 commit comments

Comments
 (0)