Skip to content

Commit 8429147

Browse files
committed
ksmbd: validate request buffer size in smb2_allocate_rsp_buf()
The response buffer should be allocated in smb2_allocate_rsp_buf before validating request. But the fields in payload as well as smb2 header is used in smb2_allocate_rsp_buf(). This patch add simple buffer size validation to avoid potencial out-of-bounds in request buffer. Signed-off-by: Namjae Jeon <[email protected]>
1 parent cf374fe commit 8429147

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

smb2pdu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,10 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
541541
if (cmd == SMB2_QUERY_INFO_HE) {
542542
struct smb2_query_info_req *req;
543543

544+
if (get_rfc1002_len(work->request_buf) <
545+
offsetof(struct smb2_query_info_req, OutputBufferLength))
546+
return -EINVAL;
547+
544548
req = smb2_get_msg(work->request_buf);
545549
if ((req->InfoType == SMB2_O_INFO_FILE &&
546550
(req->FileInfoClass == FILE_FULL_EA_INFORMATION ||

0 commit comments

Comments
 (0)