Skip to content

Commit 2724eba

Browse files
committed
usb: gadget: rndis: check size of RNDIS_MSG_SET command
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 <[email protected]> Cc: [email protected] Tested-by: Szymon Heidrich <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8895017 commit 2724eba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/usb/gadget/function/rndis.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -637,14 +637,17 @@ static int rndis_set_response(struct rndis_params *params,
637637
rndis_set_cmplt_type *resp;
638638
rndis_resp_t *r;
639639

640+
BufLength = le32_to_cpu(buf->InformationBufferLength);
641+
BufOffset = le32_to_cpu(buf->InformationBufferOffset);
642+
if ((BufLength > RNDIS_MAX_TOTAL_SIZE) ||
643+
(BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE))
644+
return -EINVAL;
645+
640646
r = rndis_add_response(params, sizeof(rndis_set_cmplt_type));
641647
if (!r)
642648
return -ENOMEM;
643649
resp = (rndis_set_cmplt_type *)r->buf;
644650

645-
BufLength = le32_to_cpu(buf->InformationBufferLength);
646-
BufOffset = le32_to_cpu(buf->InformationBufferOffset);
647-
648651
#ifdef VERBOSE_DEBUG
649652
pr_debug("%s: Length: %d\n", __func__, BufLength);
650653
pr_debug("%s: Offset: %d\n", __func__, BufOffset);

0 commit comments

Comments
 (0)