Skip to content

Commit

Permalink
usb: gadget: rndis: check size of RNDIS_MSG_SET command
Browse files Browse the repository at this point in the history
ANBZ: torvalds#590

commit 38ea1ea upstream.

Check the size of the RNDIS_MSG_SET command given to us before
attempting to respond to an invalid message size.

Reported-by: Szymon Heidrich <szymon.heidrich@gmail.com>
Cc: stable@kernel.org
Tested-by: Szymon Heidrich <szymon.heidrich@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: zhaoxinchao <zhaoxinchao@uniontech.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
  • Loading branch information
zhaoxinchao authored and josephhz committed Mar 2, 2022
1 parent 99f3fb0 commit 3a710ba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/usb/gadget/function/rndis.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,18 @@ static int rndis_set_response(struct rndis_params *params,
rndis_set_cmplt_type *resp;
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));
if (!r)
return -ENOMEM;
resp = (rndis_set_cmplt_type *)r->buf;

BufLength = le32_to_cpu(buf->InformationBufferLength);
BufOffset = le32_to_cpu(buf->InformationBufferOffset);

#ifdef VERBOSE_DEBUG
pr_debug("%s: Length: %d\n", __func__, BufLength);
Expand Down

0 comments on commit 3a710ba

Please sign in to comment.