Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp990475imu; Tue, 20 Nov 2018 09:53:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/VKXovBZjn8lZiaK6LlNx1mLUE0MX0L7lc8pmpQ4AGl0O8jOJtzx2Tip6e4SAUvZ/MvqUvl X-Received: by 2002:a63:8ac4:: with SMTP id y187mr2795320pgd.446.1542736403810; Tue, 20 Nov 2018 09:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542736403; cv=none; d=google.com; s=arc-20160816; b=oMSDdVtSit+8dpj7xX+wsENVAdTIDuCtwpKIQIBXSDW2QC2v/QamAiZCKc2Owh8c9Y PPLPB41ZjlqA0z6XxQZbSDJBB9aSUn5Byq/dqG677JxU4NA0rqfx/GhcoEzQiYg1iGWl 7aBCMgPahB2APJ7n99DxlRuNtTiSC5JDAU7O0CLtbiHrbfED9SZBmYov/BpxAcI6yduW lbrR0dEz6Zo+Xsq9+TKX4WdkrIRnPsxEyWOm1JC1GZBGSND+oQascqM9V6R3oB3vt8hw aIi7GouJK/HPyZaGz5wZZlimVVcUx7zBHrtDpA+VT3FdvKx05tf8sYVIuNBWUunCxFgk 6oOw== 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=AOZx5nmjOGWwDEkeD7k5hl79wVEnGeHOHCWH5xNMl30=; b=M7vBWMJReuqUlcO5rJmOT13WO+UNk3KD6exG+VAPmfgAis6yOMRvu33ahdczYv+dFe jrTzxKZ7/grjjftSSydRpn7N79nEOeJTGX1mXhtgaNO2ELSqsEfJ/qQC8nAGeYMvfBPe +ukxvxT5oE5gumOuck6X0SjbYXxn3b40C+yxgd/GS9gueOaw9pOnm5uKY4Mld7iVXftR ynj2MQ6hngxE4Yw/1uClwZTlHJLVyf/ci2LUfXdWeO0XNRIRq8afk4JEsB77n1ESGHKH a2GQVvd3WlTZ2PzM2m366N/w6sMqaPIAVerGYDL77qKDgJs1hNoOi3+dio5nAF3EfBlc Qrqw== 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 d36si28954331pla.216.2018.11.20.09.52.58; Tue, 20 Nov 2018 09:53:23 -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 S1729115AbeKUBoF (ORCPT + 99 others); Tue, 20 Nov 2018 20:44:05 -0500 Received: from foss.arm.com ([217.140.101.70]:50700 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbeKUBoF (ORCPT ); Tue, 20 Nov 2018 20:44:05 -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 A3E84EBD; Tue, 20 Nov 2018 07:14:28 -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 292D73F5A0; Tue, 20 Nov 2018 07:14:27 -0800 (PST) Date: Tue, 20 Nov 2018 15:14:19 +0000 From: Lorenzo Pieralisi To: Stefan Agner Cc: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, l.stach@pengutronix.de, tpiepho@impinj.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] PCI: dwc: allow to limit registers set length Message-ID: <20181120151419.GA26247@e107981-ln.cambridge.arm.com> References: <20181120132705.6917-1-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181120132705.6917-1-stefan@agner.ch> 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 Tue, Nov 20, 2018 at 02:27:03PM +0100, Stefan Agner wrote: > Add length to the struct dw_pcie and check that the accessors > dw_pcie_(rd|wr)_own_conf() do not read/write beyond that point. > > Signed-off-by: Stefan Agner > --- > drivers/pci/controller/dwc/pcie-designware-host.c | 4 ++++ > drivers/pci/controller/dwc/pcie-designware.h | 1 + > 2 files changed, 5 insertions(+) Hi Stefan, may I kindly ask you please to rebase this series against my pci/dwc branch ? I will apply it with Lucas tags then. Please CC me on the patches. Thanks, Lorenzo > diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c > index 29a05759a294..b422538ee0bb 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-host.c > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > @@ -29,6 +29,8 @@ static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, > return pp->ops->rd_own_conf(pp, where, size, val); > > pci = to_dw_pcie_from_pp(pp); > + if (pci->dbi_length && where + size > pci->dbi_length) > + return PCIBIOS_BAD_REGISTER_NUMBER; > return dw_pcie_read(pci->dbi_base + where, size, val); > } > > @@ -41,6 +43,8 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, > return pp->ops->wr_own_conf(pp, where, size, val); > > pci = to_dw_pcie_from_pp(pp); > + if (pci->dbi_length && where + size > pci->dbi_length) > + return PCIBIOS_BAD_REGISTER_NUMBER; > return dw_pcie_write(pci->dbi_base + where, size, val); > } > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h > index 9f1a5e399b70..5be5f369abf2 100644 > --- a/drivers/pci/controller/dwc/pcie-designware.h > +++ b/drivers/pci/controller/dwc/pcie-designware.h > @@ -215,6 +215,7 @@ struct dw_pcie { > struct device *dev; > void __iomem *dbi_base; > void __iomem *dbi_base2; > + int dbi_length; > u32 num_viewport; > u8 iatu_unroll_enabled; > struct pcie_port pp; > -- > 2.19.1 >