From: Yisheng Xie <xieyisheng1@huawei.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: <bhelgaas@google.com>, <lenb@kernel.org>,
<linux-pci@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <guohanjun@huawei.com>,
<jcm@redhat.com>, <toshi.kani@hpe.com>, <tanxiaojun@huawei.com>,
<wangzhou1@hisilicon.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Hanjun Guo <hanjun.guo@linaro.org>
Subject: Re: [PATCH v2 1/2] PCI ACPI: Avoid panic when PCI IO resource's size is not page aligned
Date: Mon, 7 May 2018 16:06:13 +0800 [thread overview]
Message-ID: <a8398da8-2f69-5694-69d6-224b547a378a@huawei.com> (raw)
In-Reply-To: <3699960.UXjPS91TgB@aspire.rjw.lan>
On 2018/5/1 17:28, Rafael J. Wysocki wrote:
>> drivers/acpi/pci_root.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
>> > index 6fc204a..b758ca3 100644
>> > --- a/drivers/acpi/pci_root.c
>> > +++ b/drivers/acpi/pci_root.c
>> > @@ -746,7 +746,7 @@ static void acpi_pci_root_remap_iospace(struct resource_entry *entry)
>> > goto err;
>> >
>> > res->start = port;
>> > - res->end = port + length - 1;
>> > + res->end = PAGE_ALIGN(port + length) - 1;
> Shouldn't pci_remap_iospace() sanitize its arguments instead?
Yeah, I thought that pci_remap_iospace() will be called at many place, and presently I
had not seen any problem at other place except acpi_pci_root_remap_iospace(). Anyway,
sanitize arguments in pci_remap_iospace() can resolve the problem more thoroughly, but
should more common, right?
Therefore, is the follow change ok from your point of view?
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e597655..8607298 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3527,6 +3527,9 @@ int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr)
if (res->end > IO_SPACE_LIMIT)
return -EINVAL;
+ if (!PAGE_ALIGNED(vaddr) || !PAGE_ALIGNED(resource_size(res)))
+ return -EINVAL;
+
return ioremap_page_range(vaddr, vaddr + resource_size(res), phys_addr,
pgprot_device(PAGE_KERNEL));
#else
Thanks
Yisheng
>
>> > entry->offset = port - pci_addr;
>> >
>> > if (pci_remap_iospace(res, cpu_addr) < 0)
next prev parent reply other threads:[~2018-05-07 8:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 7:12 Yisheng Xie
2018-03-31 7:12 ` [PATCH v2 2/2] PCI: Check phys_addr for pci_remap_iospace Yisheng Xie
2018-04-19 8:03 ` [PATCH v2 1/2] PCI ACPI: Avoid panic when PCI IO resource's size is not page aligned Yisheng Xie
2018-05-01 9:28 ` Rafael J. Wysocki
2018-05-07 8:06 ` Yisheng Xie [this message]
2018-05-08 21:20 ` Rafael J. Wysocki
2018-05-09 3:46 ` Yisheng Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a8398da8-2f69-5694-69d6-224b547a378a@huawei.com \
--to=xieyisheng1@huawei.com \
--cc=bhelgaas@google.com \
--cc=guohanjun@huawei.com \
--cc=hanjun.guo@linaro.org \
--cc=jcm@redhat.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=rjw@rjwysocki.net \
--cc=sudeep.holla@arm.com \
--cc=tanxiaojun@huawei.com \
--cc=toshi.kani@hpe.com \
--cc=wangzhou1@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®