Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3669487pxb; Mon, 24 Jan 2022 14:57:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvUMljIjYNMMeYf68K7oT+taLy3hwF+oE18yEdEca/REjTyow7TSDcjzPYoP+x4XHdo++r X-Received: by 2002:a05:6a00:b8c:b0:4c8:7274:c66b with SMTP id g12-20020a056a000b8c00b004c87274c66bmr9105057pfj.56.1643065061913; Mon, 24 Jan 2022 14:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065061; cv=none; d=google.com; s=arc-20160816; b=VYyDBFCfwEFeS61ZTuTnUlDOnAOXu2DcZ3qLbkDapJSh8EJ0aRN9Thgtcgiob5O0fO AD8+M9s5QIljP0f3uyCzQ7hOVLxIG4M6p+uDSQdWLyv/Y46azPeQkMFAkeGJ3LMHdqoh Qsu4IjMKTQALIMltrLksxIIgu+E8uzvHvpPUookW8sJKSQN463ba0tJn6Rxsjz3qegQ3 FTrA/znIhZZbLjGgjNJlKAh4ZropcF2RuCtuwCULZjXPYJMSna63lskWHirpfBLoD+SV 7CpgDxXs8acZjD3o4XvvVf8W2CZhIREeRVeWHApGD8VjF8SwOFEs4u1XE4qx+Fe7LSZp 5MyQ== 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=zdeErvBCNyUsFzoN7+sz675X0U1lc4MEILt69ZoYpPU=; b=XnMYdYdIQMVjS0aXU555JY/6/kDR6Db5MECMPKU8XGjPo8D3dQJNnp9xx6k2U+ftZK nTxEPNV7e+1JHz4aNZJ1NfpErQlo5bJFyMZfIQAdY5oCeHoliMZhZs0qYwdBe4EOiEvX DSng97YW5oL50UEAO9N5zkLc2jXWVdmyelOV6RliDNxQM9d8+fAyjdcByaJvHw0/fuEE VIfHEmXWLEBFHYrXRG9t0MEU7wq1MVxwlva3Sk7qwegcoMTjBv80VkV30YRXPZQoMuTK QbOcETgKJlNTgj+4E5cXctBCiWbuoBHUSpb3Iqx/+RMfbt4tDYPwFl6NwSpn1+Bh1mRt 8wlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=09WhtZQa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si13604988pff.301.2022.01.24.14.57.30; Mon, 24 Jan 2022 14:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=09WhtZQa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1355861AbiAXWyM (ORCPT + 99 others); Mon, 24 Jan 2022 17:54:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1575078AbiAXVvA (ORCPT ); Mon, 24 Jan 2022 16:51:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21C3FC08B4DD; Mon, 24 Jan 2022 12:33:47 -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 B272D6153C; Mon, 24 Jan 2022 20:33:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A48CC340E5; Mon, 24 Jan 2022 20:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056426; bh=K/eWSfljgcMu7/mLCM+m/uhl8K632G9yFcOz1ichPVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=09WhtZQakHh0ADM6I/tuhm2xdLPv0bbgffEb4b+2Mw79pz/psj9p/HarKM2hfRb4s y0fD2f/XZDe+O9P/6GWoMxZsxSx+eT3JJ1euHsbORYcKwxLMFT4S7XwfZMqtKZj+/L Dw0+7qitA/eA0nnqIRoALhNxoUuswMDzhf5WA2lo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TCS Robot , Haimin Zhang , Alan Stern , Sasha Levin Subject: [PATCH 5.15 481/846] USB: ehci_brcm_hub_control: Improve port index sanitizing Date: Mon, 24 Jan 2022 19:39:58 +0100 Message-Id: <20220124184117.607858250@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: Haimin Zhang [ Upstream commit 9933698f6119886c110750e67c10ac66f12b730f ] Due to (wIndex & 0xff) - 1 can get an integer greater than 15, this can cause array index to be out of bounds since the size of array port_status is 15. This change prevents a possible out-of-bounds pointer computation by forcing the use of a valid port number. Reported-by: TCS Robot Signed-off-by: Haimin Zhang Signed-off-by: Alan Stern Link: https://lore.kernel.org/r/20211113165320.GA59686@rowland.harvard.edu Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/ehci-brcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c index d3626bfa966b4..6a0f64c9e5e88 100644 --- a/drivers/usb/host/ehci-brcm.c +++ b/drivers/usb/host/ehci-brcm.c @@ -62,8 +62,12 @@ static int ehci_brcm_hub_control( u32 __iomem *status_reg; unsigned long flags; int retval, irq_disabled = 0; + u32 temp; - status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; + temp = (wIndex & 0xff) - 1; + if (temp >= HCS_N_PORTS_MAX) /* Avoid index-out-of-bounds warning */ + temp = 0; + status_reg = &ehci->regs->port_status[temp]; /* * RESUME is cleared when GetPortStatus() is called 20ms after start -- 2.34.1