Skip to content

Commit

Permalink
staging: ncpfs: memory corruption in ncp_read_kernel()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Mar 19, 2018
1 parent b769949 commit 4c41aa2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/staging/ncpfs/ncplib_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4c41aa2

Please sign in to comment.