summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-03-01 11:04:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-23 09:10:44 +0100
commit138d4f739b35dfb40438a0d5d7054965763bfbe7 (patch)
treefb98d16beee20e232a66d078ebbbad023c72af2a /drivers
parent98f72cd198fac47f108fb37fe94275787368c34e (diff)
downloadlinux-stable-138d4f739b35dfb40438a0d5d7054965763bfbe7.tar.gz
linux-stable-138d4f739b35dfb40438a0d5d7054965763bfbe7.tar.bz2
linux-stable-138d4f739b35dfb40438a0d5d7054965763bfbe7.zip
usb: gadget: rndis: prevent integer overflow in rndis_set_response()
commit 65f3324f4b6fed78b8761c3b74615ecf0ffa81fa upstream. If "BufOffset" is very large the "BufOffset + 8" operation can have an integer overflow. Cc: stable@kernel.org Fixes: 38ea1eac7d88 ("usb: gadget: rndis: check size of RNDIS_MSG_SET command") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/20220301080424.GA17208@kili Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/function/rndis.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 970ed1514f0b..fa0c173a0d26 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;