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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 347A7EEB57B for ; Sat, 9 Sep 2023 00:42:01 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=esVem3YA; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RjDh762dSz3dK3 for ; Sat, 9 Sep 2023 10:41:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=esVem3YA; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:40e1:4800::1; helo=sin.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) X-Greylist: delayed 67 seconds by postgrey-1.37 at boromir; Sat, 09 Sep 2023 10:40:36 AEST Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RjDfX6czZz3dCV for ; Sat, 9 Sep 2023 10:40:36 +1000 (AEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7548CCE1D30; Sat, 9 Sep 2023 00:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F077CC116A3; Sat, 9 Sep 2023 00:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694220033; bh=/w+1H8cwXL8dHZKPwJTdxt6pFx+/KQS1JwdtxMSi3iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esVem3YAUt9Q0fMsOiGo+xiy2daPkB4piACn4NAVYfPCOTptUbnH6IHSIxuXupIy0 JwD1jICsFHvi/v2mzrox+woUb/eW/GdPZZYUJPMbnOS1WiGi/Czwluk9zS7wPSYqqK rig56M89uC0DR/ze3b6nl5x8i1eZZBnxAMh8en6xAoHiR5RhqKjHnigr6/szVdgS0F C5fmxJT0EfQM9gaXAutUuiQQ/rvcnDQoZDVwuQ1zyxsu6XsnJrNnQhD0pdgcHoA23I llMS2UILXDNg2MtAk40z3mELhfKde+Wtg3aWdsviJgblGy6D2eLfeasqHGQoq/DxQM iSt6lYWQSC/iw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 09/14] usb: gadget: fsl_qe_udc: validate endpoint index for ch9 udc Date: Fri, 8 Sep 2023 20:40:09 -0400 Message-Id: <20230909004015.3580832-9-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230909004015.3580832-1-sashal@kernel.org> References: <20230909004015.3580832-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.256 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Ma Ke , Li Yang , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 2707be6282988..63109c6e55068 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -1950,6 +1950,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