]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
USB: gadget: validate interface OS descriptor requests
authorSzymon Heidrich <szymon.heidrich@gmail.com>
Mon, 24 Jan 2022 11:14:00 +0000 (12:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Feb 2022 11:51:47 +0000 (12:51 +0100)
commit 75e5b4849b81e19e9efe1654b30d7f3151c33c2c upstream.

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>
drivers/usb/gadget/composite.c

index 748f8fede5c2396dae119ef0bf86717097a5e52d..42f267ae95984cd5c561d2c67c7ec021ea4900ef 100644 (file)
@@ -1930,6 +1930,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);