Commit 38ea1eac authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

usb: gadget: rndis: check size of RNDIS_MSG_SET command

Check the size of the RNDIS_MSG_SET command given to us before
attempting to respond to an invalid message size.
Reported-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
Cc: stable@kernel.org
Tested-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 75e5b484
...@@ -637,14 +637,17 @@ static int rndis_set_response(struct rndis_params *params, ...@@ -637,14 +637,17 @@ static int rndis_set_response(struct rndis_params *params,
rndis_set_cmplt_type *resp; rndis_set_cmplt_type *resp;
rndis_resp_t *r; rndis_resp_t *r;
BufLength = le32_to_cpu(buf->InformationBufferLength);
BufOffset = le32_to_cpu(buf->InformationBufferOffset);
if ((BufLength > RNDIS_MAX_TOTAL_SIZE) ||
(BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE))
return -EINVAL;
r = rndis_add_response(params, sizeof(rndis_set_cmplt_type)); r = rndis_add_response(params, sizeof(rndis_set_cmplt_type));
if (!r) if (!r)
return -ENOMEM; return -ENOMEM;
resp = (rndis_set_cmplt_type *)r->buf; resp = (rndis_set_cmplt_type *)r->buf;
BufLength = le32_to_cpu(buf->InformationBufferLength);
BufOffset = le32_to_cpu(buf->InformationBufferOffset);
#ifdef VERBOSE_DEBUG #ifdef VERBOSE_DEBUG
pr_debug("%s: Length: %d\n", __func__, BufLength); pr_debug("%s: Length: %d\n", __func__, BufLength);
pr_debug("%s: Offset: %d\n", __func__, BufOffset); pr_debug("%s: Offset: %d\n", __func__, BufOffset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment