From nobody Tue Dec 16 08:58:08 2025 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 833F4C6FA83 for ; Mon, 26 Sep 2022 12:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234659AbiIZM3I (ORCPT ); Mon, 26 Sep 2022 08:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235841AbiIZM2p (ORCPT ); Mon, 26 Sep 2022 08:28:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 628145FAFE; Mon, 26 Sep 2022 04:08:22 -0700 (PDT) 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 55AD760C6E; Mon, 26 Sep 2022 10:32:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49350C433D6; Mon, 26 Sep 2022 10:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188373; bh=14LOge9ZT3P4ZiqBhc7nTzeEF/5VcYCWhsD0HB6YN1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLy1fZcHqwAi1BknEHaL3JNusRD4xCv/3um/b6iXriWAcRFBVyYlsq4XF6Xo8V0M2 BzCbeeXOpVC1WiHEmX6pW0UwQMOLX1MmDv8zmE0jm1kbqkNkuoV+h8Tixa0wsQP7FC SqctbAzA96CykGHUQrCwF7OrIylpsLupCY7mS+wQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stan Lu , Chunfeng Yun Subject: [PATCH 5.10 121/141] usb: xhci-mtk: fix issue of out-of-bounds array access Date: Mon, 26 Sep 2022 12:12:27 +0200 Message-Id: <20220926100758.848138877@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100754.639112000@linuxfoundation.org> References: <20220926100754.639112000@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Chunfeng Yun commit de5107f473190538a65aac7edea85209cd5c1a8f upstream. Bus bandwidth array access is based on esit, increase one will cause out-of-bounds issue; for example, when esit is XHCI_MTK_MAX_ESIT, will overstep boundary. Fixes: 7c986fbc16ae ("usb: xhci-mtk: get the microframe boundary for ESIT") Cc: Reported-by: Stan Lu Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1629189389-18779-5-git-send-email-chunfeng.= yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-mtk-sch.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -539,10 +539,12 @@ static u32 get_esit_boundary(struct mu3h u32 boundary =3D sch_ep->esit; =20 if (sch_ep->sch_tt) { /* LS/FS with TT */ - /* tune for CS */ - if (sch_ep->ep_type !=3D ISOC_OUT_EP) - boundary++; - else if (boundary > 1) /* normally esit >=3D 8 for FS/LS */ + /* + * tune for CS, normally esit >=3D 8 for FS/LS, + * not add one for other types to avoid access array + * out of boundary + */ + if (sch_ep->ep_type =3D=3D ISOC_OUT_EP && boundary > 1) boundary--; }