]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ksmbd: validate request buffer size in smb2_allocate_rsp_buf()
authorNamjae Jeon <linkinjeon@kernel.org>
Fri, 12 Apr 2024 00:45:00 +0000 (09:45 +0900)
committerSteve French <stfrench@microsoft.com>
Sat, 20 Apr 2024 01:48:47 +0000 (20:48 -0500)
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>
fs/smb/server/smb2pdu.c

index 5723bbf372d7cc93c9e1b2dbdd5082c2824f85f8..ee4b2875a021c57176d065012a75a26e64992dea 100644 (file)
@@ -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 ||