Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5770759pxb; Mon, 14 Feb 2022 07:15:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnhneiTVOrGkdiB6rawK0OjXmzMHOb4MqxnkxYUC18HJ76zfB7O7XkHBxArOpzsI3RcfMh X-Received: by 2002:a9d:7ac3:: with SMTP id m3mr82612otn.175.1644851733524; Mon, 14 Feb 2022 07:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644851733; cv=none; d=google.com; s=arc-20160816; b=GQArFEDne9jBUuqwSbL9APXIIGBMl0iVTxwhcmt7LE/HnqtmaLzlXh+zBd+fofp2Qh kGN7Iglninc/0wvPjt/Lg8gQqvCstrZbo5cM9zHhNorgliww1Nk4NBNgeqn43XLtzZBA K9j0PsA8N+NQKfyeRq0WA0TIEsTH1uR23P1fIQwJlXxt5sbhQl5PuqMdvcbHxEqpqBIh kif/nfLnBUg8Jrj3YtFsfa1tUImtly1+Yp3/8369UnhRQVs9Oz43Rug25ZjyCt0Rf6OM rUzfdXun4ZFAwO1pMwJFeUm1MzR2Ychp1nSNKWH8XeEt26bi/MTgUY1RhDahYLNYV/8X BTjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2x6hSJx2Mlgkn99+ULsjVHh3e6Vhm8qDOQu7/WgRyWM=; b=EOPtSkdY5P0Tf/s2bKuli8J7JxdOoF6acH4LZxLHVAzPiyl2APlJaR980gVMjGWzMs rQ2unoiQGFl1yXTfKibzvRypYYFVh1N+bQ9rURzJlZoeKKYUftGpMWV0brjbcg7AgHtq niGf7F+e52jOfm5P4c793X7QdL5U7AH1YnJMmYBoETooAc/Ul3N/rj6AN8aLI4QzyU7K tf4xlEL5G6HcH1HF1EUMQVsh2WPLgMSw3Hzo9ct2V2zs9c2UelEkVlLjW1JfC4QoJLfz 7GRDdw+2vPekeUuELFrEggy1ntRiPtj1SzVj7i3rczv0kt1Kv2+qs+qN44tYWmcA27Iw muuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="N/AOPdbS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx43si12650887oib.411.2022.02.14.07.15.14; Mon, 14 Feb 2022 07:15:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="N/AOPdbS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344296AbiBNJ4I (ORCPT + 99 others); Mon, 14 Feb 2022 04:56:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344830AbiBNJwE (ORCPT ); Mon, 14 Feb 2022 04:52:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F6267B542; Mon, 14 Feb 2022 01:43:18 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BED2360FA2; Mon, 14 Feb 2022 09:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9948EC340E9; Mon, 14 Feb 2022 09:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831797; bh=W/rZpCwWfP2MIfCd7ghjXQZP0wpoXvZV20V3NBzfweU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N/AOPdbSG6Z4bnPJKnW/bSPRVC+V6RlOgvCecexDWjo8I5KGPZq3wYgylUCeX7PAq +gps+2a9WGPyYDE3ite41FXQGzfTrBoXxF8QJdLq8UOHoKTRdOwQ8qUQv+bpi9QKGL 1X5qz5iooLmgp4d5txH20d9XpvN46IU1zS9jjpMo= 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 5.10 098/116] USB: gadget: validate interface OS descriptor requests Date: Mon, 14 Feb 2022 10:26:37 +0100 Message-Id: <20220214092502.161187259@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 @@ -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);