summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/function
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-09 16:37:53 +0100
committerMichael Bestas <mkbestas@lineageos.org>2022-11-05 18:58:23 +0200
commit8f0a947317e03efc21c3f43a553c3618fa623c85 (patch)
tree01f05fca61b3990073e0bea39bda48ac82317664 /drivers/usb/gadget/function
parent1541758765fffaf166fa51ff66e915004af8d086 (diff)
UPSTREAM: 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. Bug: 162326603 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> (cherry picked from commit 38ea1eac7d88072bbffb630e2b3db83ca649b826) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I61168b48de4ca79a3a28dd4d3b81779bc25554c1 (cherry picked from commit 16d19b656133457225cf69a4825faf30a0ca59a4)
Diffstat (limited to 'drivers/usb/gadget/function')
-rw-r--r--drivers/usb/gadget/function/rndis.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 1d13d79d5070..c5c8a7cc8f1d 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -650,14 +650,17 @@ 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);
pr_debug("%s: Offset: %d\n", __func__, BufOffset);