summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/composite.c
diff options
context:
space:
mode:
authorSzymon Heidrich <szymon.heidrich@gmail.com>2022-01-24 12:14:00 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-11 10:59:12 +0100
commit75e5b4849b81e19e9efe1654b30d7f3151c33c2c (patch)
tree4fce51754f077d11690321fb886a0c953c986e7b /drivers/usb/gadget/composite.c
parentusb: core: Unregister device on component_add() failure (diff)
downloadlinux-75e5b4849b81e19e9efe1654b30d7f3151c33c2c.tar.xz
linux-75e5b4849b81e19e9efe1654b30d7f3151c33c2c.zip
USB: gadget: validate interface OS descriptor requests
Stall the control endpoint in case provided index exceeds array size of MAX_CONFIG_INTERFACES or when the retrieved function pointer is null. Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/composite.c')
-rw-r--r--drivers/usb/gadget/composite.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 16f9e3423c9f..9315313108c9 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1988,6 +1988,9 @@ unknown:
if (w_index != 0x5 || (w_value >> 8))
break;
interface = w_value & 0xFF;
+ if (interface >= MAX_CONFIG_INTERFACES ||
+ !os_desc_cfg->interface[interface])
+ break;
buf[6] = w_index;
count = count_ext_prop(os_desc_cfg,
interface);