From: Szymon Heidrich Date: Mon, 24 Jan 2022 11:14:00 +0000 (+0100) Subject: USB: gadget: validate interface OS descriptor requests X-Git-Tag: MMI-RSBS31.Q1-48-36-26~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e986d44dc2c7edc9ae49e8cd5a67b83ac4ec03d;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git USB: gadget: validate interface OS descriptor requests 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. Mot-CRs-fixed: (CR) CVE-Fixed: CVE-2022-20009 Bug: 213172319 Change-Id: I12124d435012f99fe266e75c49db35f68e3c9aad Signed-off-by: Szymon Heidrich Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Gajjala Chakradhar Reviewed-on: https://gerrit.mot.com/2242218 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index c718cc1bc043..90761a626129 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1882,6 +1882,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; if (w_length == 0x0A) { count = count_ext_prop(os_desc_cfg,