From: Szymon Heidrich Date: Mon, 24 Jan 2022 11:14:00 +0000 (+0100) Subject: USB: gadget: validate interface OS descriptor requests X-Git-Tag: archive/raspbian/5.10.92-2+rpi1^2~16 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ee42b547447016df5a8a821c4742528988681e9a;p=linux.git USB: gadget: validate interface OS descriptor requests Origin: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit?id=22ec1004728548598f4f5b4a079a7873409eacfd Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2022-25258 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 Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Gbp-Pq: Topic bugfix/all Gbp-Pq: Name USB-gadget-validate-interface-OS-descriptor-requests.patch --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 8bec0cbf844..a980799900e 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1944,6 +1944,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);