diff options
author | Namjae Jeon <linkinjeon@kernel.org> | 2024-04-12 02:45:00 +0200 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-04-20 03:48:47 +0200 |
commit | 17cf0c2794bdb6f39671265aa18aea5c22ee8c4a (patch) | |
tree | 4753df1ab69cee91533f4d250cfc2fd7bb1ac96f /fs | |
parent | ksmbd: fix slab-out-of-bounds in smb2_allocate_rsp_buf (diff) | |
download | linux-17cf0c2794bdb6f39671265aa18aea5c22ee8c4a.tar.xz linux-17cf0c2794bdb6f39671265aa18aea5c22ee8c4a.zip |
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.
Cc: stable@vger.kernel.org
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/smb/server/smb2pdu.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 5723bbf372d7..ee4b2875a021 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -535,6 +535,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 || |