Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3935764pxb; Tue, 2 Nov 2021 00:47:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5uLK6lBx6BjKTApAIoFeQAgjypPDCikXOFASAB1gyzsR9uBzUoWvKPsVPbYaR4F1mMo/V X-Received: by 2002:a92:d2d1:: with SMTP id w17mr23221677ilg.281.1635839258560; Tue, 02 Nov 2021 00:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635839258; cv=none; d=google.com; s=arc-20160816; b=COnNg3UkpOvsY0Dvll9Kollc2K24f9nUoYOAAY1KtZA8mcVMN1MSvFIQnaSLVdrYkS hpgSwDK6o4WX2fgu1dziwO9k7R2cQPrU4+KIdqYiX/1WtM/G++vIAtRmd/H2PMCPRFqH D0os12vXovkEYX7IIPoY5m3lX5ptuiuPcEwFx8vkun3ACaru7hhkb4ZD+CHTRRRAO/D8 1+lzWIVySWjpB+sVdRHzMF+Hb9OSn3wIToj0h9ARE2tuzUUkdfb7dmhfpXdubtEJAVwQ +RJ0V9IBBZSA2Ro45oFTU/ETgVyfKbSRT0ewzZoTxw9Kh7UMNSdmtTpQasZouzlr2D52 e6lQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=qbB02tYMjQ6ue9qGZBRJ8S9gr/0EkY+iFqk7/OfhdSU=; b=NkZRR2JtQwRfzg7KgA11hLrxCVyG/ZW3YQH5/TSfjmnXGDzKKhf/1ciIOqzwk+DnOA MYZv+pbMsIN/xNLeSULB5E8OYoWN2NX7mHM4JflqXBkTTRSPoTg7T/w+7D5LMah40jJ6 nk1B+k3QX25hi+hoy5QFwuqTWZWR73p9rTPeiP+1FW7InCcO3M6fv87VZa6vnIjphfJP nvcZjOenxBnt8KPtLv1VbJ6mLZoT5Zr+0Q4Ff2YbXdtziU4a22j1T58cD6gKvDPIgZGl EnM6Ua5JuIabMmAXnpBoENEdFlVIDFE8/9TIzEXXZLhixB208aZgdG2bqugkymBPTn+N QotA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BhFbnPPi; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si22247432ilu.115.2021.11.02.00.47.27; Tue, 02 Nov 2021 00:47:38 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=BhFbnPPi; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbhKBHse (ORCPT + 99 others); Tue, 2 Nov 2021 03:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhKBHsc (ORCPT ); Tue, 2 Nov 2021 03:48:32 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 801C8C061714; Tue, 2 Nov 2021 00:45:58 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id g11so7370770pfv.7; Tue, 02 Nov 2021 00:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qbB02tYMjQ6ue9qGZBRJ8S9gr/0EkY+iFqk7/OfhdSU=; b=BhFbnPPiVL90b5KhHYM2HP+eTEZRg062PnJWkTw56i6SZ9dZG8pz9cEVMuN1DU0Yw9 Kob+UwPBg3n8umm2QjxQI//s2gfLZeiJLR/4IhK7tgK/tXtLj1F6ifRhZh23rUQNOhTB DW8y9ATuZdvOiE1sbhe1hRY15PsVTfCgKwanoNXGlg9QuUBM72QJzsBVZeRn4YuZ1gZ3 VgJOod/ukGHDVfmv+V1bb3ttPprBgV9rCZS6SEgagegTjb+webyJUmVR53hbcDAVRWCW akb34oEic5Dwb2a27l0U/FhIGfRzgewCkng96l4Gzd6hfQNqPyKcZ+o5hM8mtBqFgffT mjYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qbB02tYMjQ6ue9qGZBRJ8S9gr/0EkY+iFqk7/OfhdSU=; b=6gIUeWG+sZQwgrHi+cBfMbeGvkzb4cz08+pkAWV3MvjQHL8cfcJZT1nvoXT5ecRgG+ EIM9jCJgvH8Mh+T84qSVB7XY7lMB/cJhXegt5rFB5Dvs58yNafuwoBXYUPdmTvVy9sfZ S4DBfk5RSlQpFkyyQWTI0OzxQZu6NBBpy2LT6VJz7jDfn1KgmYBbFuKVxo6U0r2NCj95 /nVGkVbyMCzwq2UeaVLOmPp3EFSxuhdNRZWZaCZzlFj01ZRVMKjf92NUg65BioDvyER5 EWIrvF6lrKiC7G/Vs7lUrlGUqakdI+OcQirISlTR4g0v2BRXHA7N7oq8FkRHay+s5Fqz gVWQ== X-Gm-Message-State: AOAM531m+5iPiWLAo1FYRjrzA5zArMDKqGDCYLoRZyxjAlFTi+W7gvbz JCuPF/WaIvfaAngTDPATsgJmJ22vAzo= X-Received: by 2002:a05:6a00:15ca:b0:47f:59c4:dcf6 with SMTP id o10-20020a056a0015ca00b0047f59c4dcf6mr25978760pfu.63.1635839157626; Tue, 02 Nov 2021 00:45:57 -0700 (PDT) Received: from ELIJAHBAI-MB0.tencent.com ([103.7.29.31]) by smtp.gmail.com with ESMTPSA id u13sm14668281pga.92.2021.11.02.00.45.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Nov 2021 00:45:57 -0700 (PDT) From: Haimin Zhang X-Google-Original-From: Haimin Zhang To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Haimin Zhang , TCS Robot Subject: [PATCH] USB: array-index-out-of-bounds in ehci_brcm_hub_control Date: Tue, 2 Nov 2021 15:44:46 +0800 Message-Id: <20211102074446.87107-1-tcs_kernel@tencent.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There isn't enough check parameter `wIndex` in the function `ehci_brcm_hub_control`;due to the size of array `port_status` is 15, so it may lead to out of bounds. Signed-off-by: Haimin Zhang Reported-by: TCS Robot --- drivers/usb/host/ehci-brcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c index d3626bfa966b..4ca3eb9fcda9 100644 --- a/drivers/usb/host/ehci-brcm.c +++ b/drivers/usb/host/ehci-brcm.c @@ -63,7 +63,8 @@ static int ehci_brcm_hub_control( unsigned long flags; int retval, irq_disabled = 0; - status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; + if (wIndex && wIndex <= ports) + status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; /* * RESUME is cleared when GetPortStatus() is called 20ms after start --