* [PATCH] usb: gadget: rndis: prevent integer overflow in rndis_set_response()
@ 2022-03-01 8:04 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-03-01 8:04 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: Daehwan Jung, Muchun Song, Christian Brauner, linux-usb,
kernel-janitors
If "BufOffset" is very large the "BufOffset + 8" operation can have an
integer overflow.
Fixes: 38ea1eac7d88 ("usb: gadget: rndis: check size of RNDIS_MSG_SET command")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/gadget/function/rndis.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 00b3f6b3bb31..713efd9aefde 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -640,6 +640,7 @@ static int rndis_set_response(struct rndis_params *params,
BufLength = le32_to_cpu(buf->InformationBufferLength);
BufOffset = le32_to_cpu(buf->InformationBufferOffset);
if ((BufLength > RNDIS_MAX_TOTAL_SIZE) ||
+ (BufOffset > RNDIS_MAX_TOTAL_SIZE) ||
(BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE))
return -EINVAL;
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-01 8:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-01 8:04 [PATCH] usb: gadget: rndis: prevent integer overflow in rndis_set_response() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).