]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.18.6/cifs-check-kmalloc-before-use.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.18.6 / cifs-check-kmalloc-before-use.patch
1 From 126c97f4d0d1b5b956e8b0740c81a2b2a2ae548c Mon Sep 17 00:00:00 2001
2 From: Nicholas Mc Guire <hofrat@osadl.org>
3 Date: Thu, 23 Aug 2018 12:24:02 +0200
4 Subject: cifs: check kmalloc before use
5
6 From: Nicholas Mc Guire <hofrat@osadl.org>
7
8 commit 126c97f4d0d1b5b956e8b0740c81a2b2a2ae548c upstream.
9
10 The kmalloc was not being checked - if it fails issue a warning
11 and return -ENOMEM to the caller.
12
13 Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
14 Fixes: b8da344b74c8 ("cifs: dynamic allocation of ntlmssp blob")
15 Signed-off-by: Steve French <stfrench@microsoft.com>
16 Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
17 cc: Stable <stable@vger.kernel.org>`
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20 ---
21 fs/cifs/sess.c | 6 ++++++
22 1 file changed, 6 insertions(+)
23
24 --- a/fs/cifs/sess.c
25 +++ b/fs/cifs/sess.c
26 @@ -398,6 +398,12 @@ int build_ntlmssp_auth_blob(unsigned cha
27 goto setup_ntlmv2_ret;
28 }
29 *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL);
30 + if (!*pbuffer) {
31 + rc = -ENOMEM;
32 + cifs_dbg(VFS, "Error %d during NTLMSSP allocation\n", rc);
33 + *buflen = 0;
34 + goto setup_ntlmv2_ret;
35 + }
36 sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer;
37
38 memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8);