Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3858097ima; Mon, 4 Feb 2019 06:24:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IaxMD/MPyj6itPgyXedaCTyKm+dioa5/EGktJ2aWWj0AtWD4DvBmeqvZ8GIfZZBYzdwfQvl X-Received: by 2002:a63:9b11:: with SMTP id r17mr13311054pgd.416.1549290271839; Mon, 04 Feb 2019 06:24:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549290271; cv=none; d=google.com; s=arc-20160816; b=rK/so2BvaKB2oJceuU+NeccOfCx3M+GtLOFQLBuyZy3OP18Q2WAf0KDlEMpT2Ir35A 5T0Wx+hXvSFvBBcaIztidLmXDjYwwfIu077gD9BNbosCVOkAnz8wo56uUXIaBdAih+dD xQvPHXnOrwGl9U6wgcg/+EojeqJjm4y1qiHQymBBVVCBYltILhF8Wqjhd8BN5wDD5+Fx 5UiM3uG6g7sa3xqhPibCNOFerE2ih1ILC1xP370aVpUqeF2yn5iPEim+c7+/XyDrgJ4f DxHyIJi6XS0Dom237RhbBzsPQIf8PTz75CGG5hiZrLcG4Kp1COYH6JyRFM2qJU5qxxbr fcFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=iehwjpfgZybXR8dm3MgohVRuxmNUGSLNKWSBEPh6+mU=; b=qsZQQNhsweNiM31zQs4JTT6ERwBr224QSEXX06ERV5hcPZFnW9ZaueMOQJqEIZj1Lw eShdb/F2ITtV4uG6XYqDNkom0H41YDBdC4s2fmIK9K8eIVJ9yKA77QVogic/pMj1x+8k vats0fKjjkCMLK2ywLFmDwpjAZeVq8VeG2AeM056AigRpWEnfQNtIdhX0hugP0B2JrTY GUZP+0GwvXhkv3fDpx1DqitlOkgi0bpHKmmhyenf1/BTEsODyJMuMHBvCNQRNdwmn4gC WLecYDJODMLqLdrn7KRAROlvep3Oj+hkUvG9LH9o1TptQGCqQoO6AgOqqKARfp37vYUN kTrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si160845pgs.94.2019.02.04.06.24.15; Mon, 04 Feb 2019 06:24:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730513AbfBDM1u (ORCPT + 99 others); Mon, 4 Feb 2019 07:27:50 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55030 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729681AbfBDM1u (ORCPT ); Mon, 4 Feb 2019 07:27:50 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 783CA15AB; Mon, 4 Feb 2019 04:27:49 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CEAD33F675; Mon, 4 Feb 2019 04:27:47 -0800 (PST) Date: Mon, 4 Feb 2019 12:27:45 +0000 From: Lorenzo Pieralisi To: Stefan Agner Cc: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, l.stach@pengutronix.de, tpiepho@impinj.com, leonard.crestez@nxp.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/3] PCI: dwc: allow to limit registers set length Message-ID: <20190204122744.GB16219@e107981-ln.cambridge.arm.com> References: <20181204165528.15534-1-stefan@agner.ch> <20190130175415.GA7715@e107981-ln.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 10:08:11AM +0100, Stefan Agner wrote: > On 30.01.2019 18:54, Lorenzo Pieralisi wrote: > > On Tue, Dec 04, 2018 at 05:55:26PM +0100, Stefan Agner wrote: > >> Add length to the struct dw_pcie and check that the accessors > >> dw_pcie_(rd|wr)_conf() do not read/write beyond that point. > >> > >> Suggested-by: Trent Piepho > >> Signed-off-by: Stefan Agner > >> --- > >> Changes in v4: > >> - Move length check to dw_pcie_rd_conf > >> > >> .../pci/controller/dwc/pcie-designware-host.c | 16 ++++++++++++++-- > >> drivers/pci/controller/dwc/pcie-designware.h | 1 + > >> 2 files changed, 15 insertions(+), 2 deletions(-) > > > > Hi Stefan, > > > > I wanted to ask you if this series should be considered for v5.1 > > inclusion, it is in the PCI backlog. If it is, let me have a look > > and if it is OK to go I will likely ask you to rebase it. > > Yes please. With this last change I did not see any regression anymore > so far. > > Andrey Smirnov picked up the second patch: "PCI: imx6: introduce > drvdata". Not sure what the plan is with his patchset, if it gets merged > into v5.1 too then I probably better drop this patch and rebase ontop of > his series. You can now rebase it on top of my pci/dwc branch and send a v5, I will mark this series as superseded in the PCI patch queue. Lorenzo > Stefan > > > > > Thanks, > > Lorenzo > > > >> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c > >> index 692dd1b264fb..9fc0f7bd99f0 100644 > >> --- a/drivers/pci/controller/dwc/pcie-designware-host.c > >> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > >> @@ -606,14 +606,20 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, > >> int size, u32 *val) > >> { > >> struct pcie_port *pp = bus->sysdata; > >> + struct dw_pcie *pci; > >> > >> if (!dw_pcie_valid_device(pp, bus, PCI_SLOT(devfn))) { > >> *val = 0xffffffff; > >> return PCIBIOS_DEVICE_NOT_FOUND; > >> } > >> > >> - if (bus->number == pp->root_bus_nr) > >> + if (bus->number == pp->root_bus_nr) { > >> + pci = to_dw_pcie_from_pp(pp); > >> + if (pci->dbi_length && where + size > pci->dbi_length) > >> + return PCIBIOS_BAD_REGISTER_NUMBER; > >> + > >> return dw_pcie_rd_own_conf(pp, where, size, val); > >> + } > >> > >> return dw_pcie_rd_other_conf(pp, bus, devfn, where, size, val); > >> } > >> @@ -622,12 +628,18 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn, > >> int where, int size, u32 val) > >> { > >> struct pcie_port *pp = bus->sysdata; > >> + struct dw_pcie *pci; > >> > >> if (!dw_pcie_valid_device(pp, bus, PCI_SLOT(devfn))) > >> return PCIBIOS_DEVICE_NOT_FOUND; > >> > >> - if (bus->number == pp->root_bus_nr) > >> + if (bus->number == pp->root_bus_nr) { > >> + pci = to_dw_pcie_from_pp(pp); > >> + if (pci->dbi_length && where + size > pci->dbi_length) > >> + return PCIBIOS_BAD_REGISTER_NUMBER; > >> + > >> return dw_pcie_wr_own_conf(pp, where, size, val); > >> + } > >> > >> return dw_pcie_wr_other_conf(pp, bus, devfn, where, size, val); > >> } > >> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h > >> index 9943d8c68335..9cd7bdc94200 100644 > >> --- a/drivers/pci/controller/dwc/pcie-designware.h > >> +++ b/drivers/pci/controller/dwc/pcie-designware.h > >> @@ -229,6 +229,7 @@ struct dw_pcie { > >> void __iomem *dbi_base2; > >> /* Used when iatu_unroll_enabled is true */ > >> void __iomem *atu_base; > >> + int dbi_length; > >> u32 num_viewport; > >> u8 iatu_unroll_enabled; > >> struct pcie_port pp; > >> -- > >> 2.19.1 > >>