From: Bjorn Helgaas <bhelgaas@google.com>
To: "Michel Dänzer" <michel@daenzer.net>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Federico <federicotg@gmail.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] pci: Fix infinite loop with ROM image of size 0
Date: Fri, 23 Jan 2015 17:51:11 -0600 [thread overview]
Message-ID: <20150123235111.GX29776@google.com> (raw)
In-Reply-To: <1421657600-31561-1-git-send-email-michel@daenzer.net>
On Mon, Jan 19, 2015 at 05:53:20PM +0900, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> If the image size would ever read as 0, pci_get_rom_size could keep
> processing the same image over and over again.
>
> Reported-by: Federico <federicotg@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Applied with Alex's ack to pci/resource for v3.20, thanks!
> ---
>
> v2:
> * Use unsigned instead of u16 for the local length variable (not sure if
> the multiplication by 512 could overflow otherwise)
> * Integrate length condition into while statement
> * Add stable tag
>
> drivers/pci/rom.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
> index f955edb..eb0ad53 100644
> --- a/drivers/pci/rom.c
> +++ b/drivers/pci/rom.c
> @@ -71,6 +71,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
> {
> void __iomem *image;
> int last_image;
> + unsigned length;
>
> image = rom;
> do {
> @@ -93,9 +94,9 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
> if (readb(pds + 3) != 'R')
> break;
> last_image = readb(pds + 21) & 0x80;
> - /* this length is reliable */
> - image += readw(pds + 16) * 512;
> - } while (!last_image);
> + length = readw(pds + 16);
> + image += length * 512;
> + } while (length && !last_image);
>
> /* never return a size larger than the PCI resource window */
> /* there are known ROMs that get the size wrong */
> --
> 2.1.4
>
WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <bhelgaas@google.com>
To: "Michel Dänzer" <michel@daenzer.net>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, Federico <federicotg@gmail.com>
Subject: Re: [PATCH v2] pci: Fix infinite loop with ROM image of size 0
Date: Fri, 23 Jan 2015 17:51:11 -0600 [thread overview]
Message-ID: <20150123235111.GX29776@google.com> (raw)
In-Reply-To: <1421657600-31561-1-git-send-email-michel@daenzer.net>
On Mon, Jan 19, 2015 at 05:53:20PM +0900, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> If the image size would ever read as 0, pci_get_rom_size could keep
> processing the same image over and over again.
>
> Reported-by: Federico <federicotg@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Applied with Alex's ack to pci/resource for v3.20, thanks!
> ---
>
> v2:
> * Use unsigned instead of u16 for the local length variable (not sure if
> the multiplication by 512 could overflow otherwise)
> * Integrate length condition into while statement
> * Add stable tag
>
> drivers/pci/rom.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
> index f955edb..eb0ad53 100644
> --- a/drivers/pci/rom.c
> +++ b/drivers/pci/rom.c
> @@ -71,6 +71,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
> {
> void __iomem *image;
> int last_image;
> + unsigned length;
>
> image = rom;
> do {
> @@ -93,9 +94,9 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
> if (readb(pds + 3) != 'R')
> break;
> last_image = readb(pds + 21) & 0x80;
> - /* this length is reliable */
> - image += readw(pds + 16) * 512;
> - } while (!last_image);
> + length = readw(pds + 16);
> + image += length * 512;
> + } while (length && !last_image);
>
> /* never return a size larger than the PCI resource window */
> /* there are known ROMs that get the size wrong */
> --
> 2.1.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-01-23 23:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-11 1:58 Softlockup on boot with Cape Verde XT on many kernels Federico
2015-01-11 17:19 ` Alex Deucher
[not found] ` <CAFUqUc7qXoNQJwyXJtcx=6gmG0hwnHeor-NyfoPPchX9EYTDzA@mail.gmail.com>
2015-01-11 19:44 ` Fwd: " Federico
2015-01-11 20:27 ` Federico
2015-01-12 21:48 ` Alex Deucher
2015-01-12 23:34 ` Federico
2015-01-13 7:06 ` Michel Dänzer
2015-01-13 18:20 ` Federico
2015-01-14 2:19 ` Michel Dänzer
2015-01-14 3:41 ` Federico
2015-01-14 3:54 ` Michel Dänzer
2015-01-14 13:29 ` Federico
2015-01-15 0:10 ` Federico
2015-01-15 2:10 ` Federico
2015-01-15 2:46 ` Michel Dänzer
2015-01-15 2:59 ` Federico
2015-01-15 3:14 ` Federico
2015-01-15 3:53 ` Federico
2015-01-15 6:21 ` Michel Dänzer
2015-01-15 20:33 ` Federico
2015-01-16 13:02 ` Federico
2015-01-19 8:53 ` [PATCH v2] pci: Fix infinite loop with ROM image of size 0 Michel Dänzer
2015-01-19 8:53 ` Michel Dänzer
2015-01-19 18:48 ` Alex Deucher
2015-01-23 23:51 ` Bjorn Helgaas [this message]
2015-01-23 23:51 ` Bjorn Helgaas
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=20150123235111.GX29776@google.com \
--to=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=federicotg@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=michel@daenzer.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.