diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2018-03-19 14:07:45 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-08 12:49:41 +0300 |
commit | 43f8ff29c37bf96b918a8fa1a9a2c13d28603044 (patch) | |
tree | c62e4806afdec484471b84893544dd74840e354a /fs/ncpfs | |
parent | 23c8c15439f66ed7453e6490acf7c8b86ca21557 (diff) | |
download | linux-43f8ff29c37bf96b918a8fa1a9a2c13d28603044.tar.xz |
staging: ncpfs: memory corruption in ncp_read_kernel()
commit 4c41aa24baa4ed338241d05494f2c595c885af8f upstream.
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@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ncpfs')
-rw-r--r-- | fs/ncpfs/ncplib_kernel.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c index 482387532f54..9fb4fe875a75 100644 --- a/fs/ncpfs/ncplib_kernel.c +++ b/fs/ncpfs/ncplib_kernel.c @@ -980,6 +980,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); |