Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: rndis: prevent integer overflow in rndis_set_response()

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>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
65f3324f 7e57714c

+1
+1
drivers/usb/gadget/function/rndis.c
··· 640 640 BufLength = le32_to_cpu(buf->InformationBufferLength); 641 641 BufOffset = le32_to_cpu(buf->InformationBufferOffset); 642 642 if ((BufLength > RNDIS_MAX_TOTAL_SIZE) || 643 + (BufOffset > RNDIS_MAX_TOTAL_SIZE) || 643 644 (BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE)) 644 645 return -EINVAL; 645 646