From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAE3DC433FE for ; Mon, 14 Feb 2022 09:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243405AbiBNJbn (ORCPT ); Mon, 14 Feb 2022 04:31:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243386AbiBNJab (ORCPT ); Mon, 14 Feb 2022 04:30:31 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0622725E82; Mon, 14 Feb 2022 01:29:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A25D7B80DC5; Mon, 14 Feb 2022 09:29:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1C4FC340E9; Mon, 14 Feb 2022 09:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644830983; bh=XoX8f04SIwYd5Jl0Qaw+mYiEIY8/RrLJyOWhYZces3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLCxSe9Zp2HIk1LbwApsn1u4w+Z28lF/RlQYZgTx+UOB5mHFotPjRqlcfnI+bVS64 3MHNeiMHqL1wZpGgFUdwi9vwABUxmUh2tTzxpTlb0qBj8iwQKbPun2kJkGYQeGxVEY TbI03FafSotMklWMrJeMVpo5OK+pGuusE1kXqEGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Szymon Heidrich , stable@kernel.org Subject: [PATCH 4.9 27/34] USB: gadget: validate interface OS descriptor requests Date: Mon, 14 Feb 2022 10:25:53 +0100 Message-Id: <20220214092446.821501136@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092445.946718557@linuxfoundation.org> References: <20220214092445.946718557@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Szymon Heidrich 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 --- drivers/usb/gadget/composite.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1932,6 +1932,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,