[CVE-2018-8822][Trusty][SRU][PATCH] staging: ncpfs: memory corruption in ncp_read_kernel()

Po-Hsu Lin po-hsu.lin at canonical.com
Mon Apr 23 08:45:35 UTC 2018


From: Dan Carpenter <dan.carpenter at oracle.com>

CVE-2018-8822

If the server is malicious then *bytes_read could be larger than the
size of the "target" buffer.  It would lead to memory corruption when we
do the memcpy().

Reported-by: Dr Silvio Cesare of InfoSect <Silvio Cesare <silvio.cesare at gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
Cc: stable <stable at vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
(backported from commit 4c41aa24baa4ed338241d05494f2c595c885af8f)
Signed-off-by: Po-Hsu Lin <po-hsu.lin at canonical.com>
---
 fs/ncpfs/ncplib_kernel.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index 981a956..76c6a8e 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -982,6 +982,10 @@ ncp_read_kernel(struct ncp_server *server, const char *file_id,
 		goto out;
 	}
 	*bytes_read = ncp_reply_be16(server, 0);
+	if (*bytes_read > to_read) {
+		result = -EINVAL;
+		goto out;
+	}
 	source = ncp_reply_data(server, 2 + (offset & 1));
 
 	memcpy(target, source, *bytes_read);
-- 
2.7.4





More information about the kernel-team mailing list