[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180319110745.GA12001@mwanda>
Date: Mon, 19 Mar 2018 14:07:45 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Petr Vandrovec <petr@...drovec.name>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Philippe Ombredanne <pombredanne@...b.com>,
Stephen Hemminger <stephen@...workplumber.org>,
Thomas Gleixner <tglx@...utronix.de>,
"David S. Miller" <davem@...emloft.net>,
devel@...verdev.osuosl.org, netdev@...r.kernel.org,
security@...nel.org
Subject: [PATCH] ncpfs: memory corruption in ncp_read_kernel()
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@...il.com>
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
diff --git a/drivers/staging/ncpfs/ncplib_kernel.c b/drivers/staging/ncpfs/ncplib_kernel.c
index 804adfebba2f..3e047eb4cc7c 100644
--- a/drivers/staging/ncpfs/ncplib_kernel.c
+++ b/drivers/staging/ncpfs/ncplib_kernel.c
@@ -981,6 +981,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);
Powered by blists - more mailing lists