Skip to content

Commit

Permalink
ksmbd: validate request buffer size in smb2_allocate_rsp_buf()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
namjaejeon committed Apr 16, 2024
1 parent 2b15f0e commit 5f00283
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
if (cmd == SMB2_QUERY_INFO_HE) {
struct smb2_query_info_req *req;

if (get_rfc1002_len(work->request_buf) <
offsetof(struct smb2_query_info_req, OutputBufferLength))
return -EINVAL;

req = smb2_get_msg(work->request_buf);
if ((req->InfoType == SMB2_O_INFO_FILE &&
(req->FileInfoClass == FILE_FULL_EA_INFORMATION ||
Expand Down

0 comments on commit 5f00283

Please sign in to comment.