]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: Add check for next_buffer in receive_encrypted_standard()
authorHaoxiang Li <haoxiang_li2024@163.com>
Mon, 17 Feb 2025 07:20:38 +0000 (15:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Feb 2025 12:34:21 +0000 (04:34 -0800)
commit 860ca5e50f73c2a1cef7eefc9d39d04e275417f7 upstream.

Add check for the return value of cifs_buf_get() and cifs_small_buf_get()
in receive_encrypted_standard() to prevent null pointer dereference.

Fixes: eec04ea11969 ("smb: client: fix OOB in receive_encrypted_standard()")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/client/smb2ops.c

index a588f6b3f3b6a55128aed372c20c62bb5dbcfc7c..793e9b2b79d6f9b6f39d3e6d1f8e0de5cd7349ad 100644 (file)
@@ -4964,6 +4964,10 @@ one_more:
                        next_buffer = (char *)cifs_buf_get();
                else
                        next_buffer = (char *)cifs_small_buf_get();
+               if (!next_buffer) {
+                       cifs_server_dbg(VFS, "No memory for (large) SMB response\n");
+                       return -1;
+               }
                memcpy(next_buffer, buf + next_cmd, pdu_length - next_cmd);
        }