Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp945993rdb; Sat, 9 Sep 2023 02:16:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF2f4LO0tDTTPaahO8eofcL41BnOLgY0cuSoCpvSSoWis9VBq1KpGTtqERW2X5ii3U85au X-Received: by 2002:a05:6a21:33a7:b0:14e:9092:4291 with SMTP id yy39-20020a056a2133a700b0014e90924291mr6425916pzb.7.1694250979578; Sat, 09 Sep 2023 02:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694250979; cv=none; d=google.com; s=arc-20160816; b=yaqKMSIVdyq0lGnyPNaO5CmBroa9ZcjEfqfbKvbnEmTfX3774Ylkt27IbdO4qlHJbo zCv1S/fIOA2e1a/0d6h2dY2yq+/g+e8CPYJWDmMULXQVXueHwNsPxN7OlNGvwzK/ZKf+ +0mhqiBDB6xIjRqZaFPGzcTGDMLK6V1wp3Y8cPwXVKgik1sdOAMUEDePesNKmlz5duWv ccCND3vCPPJ6eeaCSlCWtHg5YAclGQQ9cg66oHsGA9m4bt7PmD+Q4Nur5BrM+SnK/Im/ GMrfrgGXUGm4rKg7dNq9caJgjIOaDBx1+jx76rsCu4R/CkZuK3p7lb/EvAa4ADILuq2M gGJA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yLA2LMLsesEHgEGj6AbB8WD/kK/1fN3BNcAk83GNNqs=; fh=04Y2LeZfm2y9YWCOgqO1ueJv1eBneHq9F80A5TpjfRg=; b=dHtR1eLwkN7+Age+4rl15LgWGR29TYHDGXXs2Dityv5w9bV3p6bSunHUeAo/080ukC B+4oIkSHfOM8y5EzlTKtTlWI9rZgmWDbt0/pbMMJq3NTMAc9uLBklVsSgaCq7LJtDE4m uxkMii/7RHjgM+G7mYXORbSg5J46EsBmv8aAk6yKonHHqxrE0FusfHdeCKisnpRCJwqv tdbCYWpVNMk7PTb8UkTVpBUCiQWBgmgf2AfhJDLxFCtjlLtNgdNwNYOzwCUOmtrVh1VK oWj/JFxDoejRfAGKwBjK57A2EI3ld98dLQJJaDsM13bKrH2xEpKoX+30tiwi84QILCSp ohNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DGPFegxt; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq7-20020a056a000e0700b0068c0042d3dfsi2911700pfb.114.2023.09.09.02.16.03; Sat, 09 Sep 2023 02:16:19 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=DGPFegxt; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346122AbjIIAmJ (ORCPT + 99 others); Fri, 8 Sep 2023 20:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346037AbjIIAk3 (ORCPT ); Fri, 8 Sep 2023 20:40:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D57210C; Fri, 8 Sep 2023 17:39:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFA95C43140; Sat, 9 Sep 2023 00:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694219965; bh=TPIuh+2sJJpu77e2C3tJB6Yh9/wzL5z2S91+OFaBVqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DGPFegxtTLGPkPZdeufLknNLKhblXvLn6AMLQei8/Fm+sTSigHUizSY8t+1WocEul 7uOqAfO0xUndgau1qsYM3R53xDjxAmkYOGAOcHtEi38GdDcrl2s9shgJYT61RPTN92 NB2CRpCPEl+ue9SFM3QJQQ3bqGQI0pruuodwHw8mAJB1QRVc4buKYwHoeT2HnOeI24 VZAK9zdszRDarQ3+HkwdmOe5JdKQcYcF5tntxf8bh0P4yQAOs15sRaUrImRbBjR2hb 5EpN9RiVnmuN/OI+miJMs738gE2JbOj+Tf5CqDd2lBd+KEC5C8zr7Ps4fESde3GA47 PYP4CfG/7jDCg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ma Ke , Li Yang , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.15 11/19] usb: gadget: fsl_qe_udc: validate endpoint index for ch9 udc Date: Fri, 8 Sep 2023 20:38:55 -0400 Message-Id: <20230909003903.3580394-11-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230909003903.3580394-1-sashal@kernel.org> References: <20230909003903.3580394-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.131 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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: Ma Ke [ Upstream commit ce9daa2efc0872a9a68ea51dc8000df05893ef2e ] We should verify the bound of the array to assure that host may not manipulate the index to point past endpoint array. Signed-off-by: Ma Ke Acked-by: Li Yang Link: https://lore.kernel.org/r/20230628081511.186850-1-make_ruc2021@163.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/fsl_qe_udc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index 15db7a3868fe4..aff4050f96dd6 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -1956,6 +1956,8 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_ENDPOINT) { /* Get endpoint status */ int pipe = index & USB_ENDPOINT_NUMBER_MASK; + if (pipe >= USB_MAX_ENDPOINTS) + goto stall; struct qe_ep *target_ep = &udc->eps[pipe]; u16 usep; -- 2.40.1