]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.132/cifs-read-overflow-in-is_valid_oplock_break.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.9.132 / cifs-read-overflow-in-is_valid_oplock_break.patch
CommitLineData
80347ec8
GKH
1From foo@baz Mon Oct 8 18:01:43 CEST 2018
2From: Dan Carpenter <dan.carpenter@oracle.com>
3Date: Thu, 6 Sep 2018 12:47:01 +0300
4Subject: cifs: read overflow in is_valid_oplock_break()
5
6From: Dan Carpenter <dan.carpenter@oracle.com>
7
8[ Upstream commit 097f5863b1a0c9901f180bbd56ae7d630655faaa ]
9
10We need to verify that the "data_offset" is within bounds.
11
12Reported-by: Dr Silvio Cesare of InfoSect <silvio.cesare@gmail.com>
13Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
14Signed-off-by: Steve French <stfrench@microsoft.com>
15Reviewed-by: Aurelien Aptel <aaptel@suse.com>
16Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
17Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18---
19 fs/cifs/misc.c | 8 ++++++++
20 1 file changed, 8 insertions(+)
21
22--- a/fs/cifs/misc.c
23+++ b/fs/cifs/misc.c
24@@ -406,9 +406,17 @@ is_valid_oplock_break(char *buffer, stru
25 (struct smb_com_transaction_change_notify_rsp *)buf;
26 struct file_notify_information *pnotify;
27 __u32 data_offset = 0;
28+ size_t len = srv->total_read - sizeof(pSMBr->hdr.smb_buf_length);
29+
30 if (get_bcc(buf) > sizeof(struct file_notify_information)) {
31 data_offset = le32_to_cpu(pSMBr->DataOffset);
32
33+ if (data_offset >
34+ len - sizeof(struct file_notify_information)) {
35+ cifs_dbg(FYI, "invalid data_offset %u\n",
36+ data_offset);
37+ return true;
38+ }
39 pnotify = (struct file_notify_information *)
40 ((char *)&pSMBr->hdr.Protocol + data_offset);
41 cifs_dbg(FYI, "dnotify on %s Action: 0x%x\n",