From patchwork Thu Oct 1 06:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11810927 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D23AA6CB for ; Thu, 1 Oct 2020 06:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 989FE221E7 for ; Thu, 1 Oct 2020 06:01:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="J9cegQ27" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725960AbgJAGBO (ORCPT ); Thu, 1 Oct 2020 02:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbgJAGBO (ORCPT ); Thu, 1 Oct 2020 02:01:14 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EEF7C0613D0 for ; Wed, 30 Sep 2020 23:01:14 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u24so3198672pgi.1 for ; Wed, 30 Sep 2020 23:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n/EKXhfktXa8OD3A0+KlBuM2uKvfFs6/Sk7F67lxoIM=; b=J9cegQ27GhtaMCmVvEukmBJixsp27ubstP/U5uFHPQA0qAXwdYIt+Pmk9qG1fc8OtR mZL4wgEsbuCjkxaUBxWfCv6l9cbBMyjSAMyH211V7HkRclSmK5xD64mv3JI8k0fFuRj8 mV9+s0u91HfRt+b27GfXkE+qyInG1y8Z5XmiA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n/EKXhfktXa8OD3A0+KlBuM2uKvfFs6/Sk7F67lxoIM=; b=Q5ylRgYo4ShBkLIKI7IKJmtRU8D9IA704OWtBTNQ7zcxObQazW0hNQIdpObb+wowPx tN3XcFrxDUhgFa7kM0kOYAuIcFuivadc+yhBc5TVCPvHT7wG7ncnEer9dk0C7DHY1g/4 zYT7qbunTa84Ny3SDPmL46xRvCCDPpQwKNvHZ7kr6M5rGNp9VJutcmzLDAeEDQLKtakY NY2frwTJW1SRNO/dcGGPHij+seO7tCT3Pe5Bmp+ldopTiZWFuDrppOvtEKumJ6jB9zuF PSE5UyKMvdeNONkxgVvz1JSkVWv48Xrvot1Xwbn+1SauovRKYsUv78kLR2Lh9pGBiYdR DlmQ== X-Gm-Message-State: AOAM530nFxUS2XLpQosn7FKM4XGwyGpTtTd9tpjY+CHS3nntDNLDWE1f HEX+YicYbmLCKOeGH9IzaPx67A== X-Google-Smtp-Source: ABdhPJwMOxEq67OVw9EpZDWFCHL+80TRYJXCJ4LW3yfGXNtJPqy9Altdc4qlVorZ1gdeJ4G7Ati9fg== X-Received: by 2002:a63:8c6:: with SMTP id 189mr4976473pgi.207.1601532073802; Wed, 30 Sep 2020 23:01:13 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l2sm4032112pjy.3.2020.09.30.23.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 23:01:13 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Ray Jui Cc: bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bharat Gooty Subject: [PATCH v3 1/3] PCI: iproc: Fix out-of-bound array accesses Date: Thu, 1 Oct 2020 11:30:52 +0530 Message-Id: <20201001060054.6616-2-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201001060054.6616-1-srinath.mannam@broadcom.com> References: <20201001060054.6616-1-srinath.mannam@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Bharat Gooty Declare the full size array for all revisions of PAX register sets to avoid potentially out of bound access of the register array when they are being initialized in iproc_pcie_rev_init(). Fixes: 06324ede76cdf ("PCI: iproc: Improve core register population") Signed-off-by: Bharat Gooty --- drivers/pci/controller/pcie-iproc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 905e93808243..d901b9d392b8 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -307,7 +307,7 @@ enum iproc_pcie_reg { }; /* iProc PCIe PAXB BCMA registers */ -static const u16 iproc_pcie_reg_paxb_bcma[] = { +static const u16 iproc_pcie_reg_paxb_bcma[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x120, [IPROC_PCIE_CFG_IND_DATA] = 0x124, @@ -318,7 +318,7 @@ static const u16 iproc_pcie_reg_paxb_bcma[] = { }; /* iProc PCIe PAXB registers */ -static const u16 iproc_pcie_reg_paxb[] = { +static const u16 iproc_pcie_reg_paxb[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x120, [IPROC_PCIE_CFG_IND_DATA] = 0x124, @@ -334,7 +334,7 @@ static const u16 iproc_pcie_reg_paxb[] = { }; /* iProc PCIe PAXB v2 registers */ -static const u16 iproc_pcie_reg_paxb_v2[] = { +static const u16 iproc_pcie_reg_paxb_v2[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x120, [IPROC_PCIE_CFG_IND_DATA] = 0x124, @@ -363,7 +363,7 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { }; /* iProc PCIe PAXC v1 registers */ -static const u16 iproc_pcie_reg_paxc[] = { +static const u16 iproc_pcie_reg_paxc[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x1f0, [IPROC_PCIE_CFG_IND_DATA] = 0x1f4, @@ -372,7 +372,7 @@ static const u16 iproc_pcie_reg_paxc[] = { }; /* iProc PCIe PAXC v2 registers */ -static const u16 iproc_pcie_reg_paxc_v2[] = { +static const u16 iproc_pcie_reg_paxc_v2[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_MSI_GIC_MODE] = 0x050, [IPROC_PCIE_MSI_BASE_ADDR] = 0x074, [IPROC_PCIE_MSI_WINDOW_SIZE] = 0x078,