All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] PCI: Avoid access memory outside the resource window
@ 2018-06-05  1:46 Rex Zhu
  2018-06-05  1:46 ` [PATCH 2/2] PCI: Add check code for last image indicator not set Rex Zhu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rex Zhu @ 2018-06-05  1:46 UTC (permalink / raw)
  To: bhelgaas, michel.daenzer, alexander.deucher, linux-pci; +Cc: Rex Zhu

change ">" to ">=" to avoid access beyond the actual
length of io memory.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/pci/rom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 374a334..a5c6016 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -108,7 +108,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
 		length = readw(pds + 16);
 		image += length * 512;
 		/* Avoid iterating through memory outside the resource window */
-		if (image > rom + size)
+		if (image >= rom + size)
 			break;
 	} while (length && !last_image);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] PCI: Add check code for last image indicator not set
  2018-06-05  1:46 [PATCH 1/2] PCI: Avoid access memory outside the resource window Rex Zhu
@ 2018-06-05  1:46 ` Rex Zhu
  2018-06-12 14:34 ` [PATCH 1/2] PCI: Avoid access memory outside the resource window Deucher, Alexander
  2018-06-30  2:20 ` Bjorn Helgaas
  2 siblings, 0 replies; 4+ messages in thread
From: Rex Zhu @ 2018-06-05  1:46 UTC (permalink / raw)
  To: bhelgaas, michel.daenzer, alexander.deucher, linux-pci; +Cc: Rex Zhu

if last image indicator was not set in the PCI data struct,
print out "No more image in the PCI ROM" instand of
loop back and print "Invalid PCI ROM header signature" info.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/pci/rom.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index a5c6016..a8b916b 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -110,6 +110,12 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
 		/* Avoid iterating through memory outside the resource window */
 		if (image >= rom + size)
 			break;
+		if (!last_image) {
+			if (readw(image) != 0xAA55) {
+				pci_info(pdev, "No more image in the PCI ROM\n");
+				break;
+			}
+		}
 	} while (length && !last_image);
 
 	/* never return a size larger than the PCI resource window */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/2] PCI: Avoid access memory outside the resource window
  2018-06-05  1:46 [PATCH 1/2] PCI: Avoid access memory outside the resource window Rex Zhu
  2018-06-05  1:46 ` [PATCH 2/2] PCI: Add check code for last image indicator not set Rex Zhu
@ 2018-06-12 14:34 ` Deucher, Alexander
  2018-06-30  2:20 ` Bjorn Helgaas
  2 siblings, 0 replies; 4+ messages in thread
From: Deucher, Alexander @ 2018-06-12 14:34 UTC (permalink / raw)
  To: Zhu, Rex, bhelgaas, Daenzer, Michel, linux-pci; +Cc: Zhu, Rex

> -----Original Message-----
> From: Rex Zhu [mailto:Rex.Zhu@amd.com]
> Sent: Monday, June 4, 2018 9:47 PM
> To: bhelgaas@google.com; Daenzer, Michel <Michel.Daenzer@amd.com>;
> Deucher, Alexander <Alexander.Deucher@amd.com>; linux-
> pci@vger.kernel.org
> Cc: Zhu, Rex <Rex.Zhu@amd.com>
> Subject: [PATCH 1/2] PCI: Avoid access memory outside the resource
> window
>=20
> change ">" to ">=3D" to avoid access beyond the actual length of io memor=
y.
>=20
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/pci/rom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>=20
> diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 374a334..a5c6016
> 100644
> --- a/drivers/pci/rom.c
> +++ b/drivers/pci/rom.c
> @@ -108,7 +108,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void
> __iomem *rom, size_t size)
>  		length =3D readw(pds + 16);
>  		image +=3D length * 512;
>  		/* Avoid iterating through memory outside the resource
> window */
> -		if (image > rom + size)
> +		if (image >=3D rom + size)
>  			break;
>  	} while (length && !last_image);
>=20
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] PCI: Avoid access memory outside the resource window
  2018-06-05  1:46 [PATCH 1/2] PCI: Avoid access memory outside the resource window Rex Zhu
  2018-06-05  1:46 ` [PATCH 2/2] PCI: Add check code for last image indicator not set Rex Zhu
  2018-06-12 14:34 ` [PATCH 1/2] PCI: Avoid access memory outside the resource window Deucher, Alexander
@ 2018-06-30  2:20 ` Bjorn Helgaas
  2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2018-06-30  2:20 UTC (permalink / raw)
  To: Rex Zhu; +Cc: bhelgaas, michel.daenzer, alexander.deucher, linux-pci

On Tue, Jun 05, 2018 at 09:46:45AM +0800, Rex Zhu wrote:
> change ">" to ">=" to avoid access beyond the actual
> length of io memory.
> 
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>

Both applied with Alex's reviewed-by to pci/resource for v4.19, thanks!

I also added a patch to make pci_get_rom_size() static, since it's only
used by pci_map_rom().

> ---
>  drivers/pci/rom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
> index 374a334..a5c6016 100644
> --- a/drivers/pci/rom.c
> +++ b/drivers/pci/rom.c
> @@ -108,7 +108,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
>  		length = readw(pds + 16);
>  		image += length * 512;
>  		/* Avoid iterating through memory outside the resource window */
> -		if (image > rom + size)
> +		if (image >= rom + size)
>  			break;
>  	} while (length && !last_image);
>  
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-30  2:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05  1:46 [PATCH 1/2] PCI: Avoid access memory outside the resource window Rex Zhu
2018-06-05  1:46 ` [PATCH 2/2] PCI: Add check code for last image indicator not set Rex Zhu
2018-06-12 14:34 ` [PATCH 1/2] PCI: Avoid access memory outside the resource window Deucher, Alexander
2018-06-30  2:20 ` Bjorn Helgaas

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.