pci: fix address range check in __pci_hose_phys_to_bus()
PATCH 1/1 pci: fix address range check in __pci_hose_phys_to_bus()
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both 0x80000000 leading to the following messages:
Apalis TK1 # tftpboot $loadaddr test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address: 0x80408000
Loading: pci_hose_phys_to_bus: invalid physical address
This patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in __pci_hose_bus_to_phys().
---
drivers/pci/pci_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci_common.c +1 -1
@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose, bus_addr = phys_addr - res->phys_start + res->bus_start;if (bus_addr >= res->bus_start && - bus_addr < res->bus_start + res->size) { + (bus_addr - res->bus_start) < res->size) { *ba = bus_addr;return 0 ; }
Signature · 1 line
2.5.0
PATCH 1/1 pci: fix address range check in __pci_hose_phys_to_bus()
Quoted 28 lines · Marcel Ziswiler
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both
0x80000000leading to the following messages:Apalis TK1 # tftpboot $loadaddr
test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address:0x80408000
Loading:pci_hose_phys_to_bus: invalid physical addressThis patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in
__pci_hose_bus_to_phys().Reported-by Ivan Mercier <[email protected]>Signed-off-by Marcel Ziswiler <[email protected]>---
drivers/pci/pci_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci_common.c +0
-0
drivers/pci/pci_common.c int __pci_hose_phys_to_bus(struct pci_controller *hose,
Quoted 9 lines
drivers/pci/pci_common.c +1
-2@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose, bus_addr = phys_addr - res->phys_start + res->bus_start;if (bus_addr >= res->bus_start && - bus_addr < res->bus_start + res->size) { + (bus_addr - res->bus_start) < res->size) { *ba = bus_addr;return 0 ; } --
PATCH 1/1 pci: fix address range check in __pci_hose_phys_to_bus()
Well done Marcel!
I didn't have much more time to investigate on it. OK with nvidia jetson TK1 with i210 AND RTL8169.
Quoted 41 lines · Bin Meng
Quoted 28 lines · Marcel Ziswiler
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both
0x80000000leading to the following messages:Apalis TK1 # tftpboot $loadaddr
test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address:0x80408000
Loading:pci_hose_phys_to_bus: invalid physical addressThis patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in
__pci_hose_bus_to_phys().Reported-by Ivan Mercier <[email protected]>Signed-off-by Marcel Ziswiler <[email protected]>---
drivers/pci/pci_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci_common.c +0
-0drivers/pci/pci_common.c int __pci_hose_phys_to_bus(struct pci_controller *hose,
Quoted 9 lines
drivers/pci/pci_common.c +1
-2@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose, bus_addr = phys_addr - res->phys_start + res->bus_start;if (bus_addr >= res->bus_start && - bus_addr < res->bus_start + res->size) { + (bus_addr - res->bus_start) < res->size) { *ba = bus_addr;return 0 ; } --Reviewed-by Bin Meng <[email protected]>
PATCH 1/1 pci: fix address range check in __pci_hose_phys_to_bus()
In reply to Marcel ZiswilerQuoted 28 lines · Marcel Ziswiler
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both
0x80000000leading to the following messages:Apalis TK1 # tftpboot $loadaddr
test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address:0x80408000
Loading:pci_hose_phys_to_bus: invalid physical addressThis patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in
__pci_hose_bus_to_phys().Reported-by Ivan Mercier <[email protected]>Signed-off-by Marcel Ziswiler <[email protected]>---
drivers/pci/pci_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci_common.c +0
-0
drivers/pci/pci_common.c int __pci_hose_phys_to_bus(struct pci_controller *hose,
Quoted 9 lines
drivers/pci/pci_common.c +1
-2@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose, bus_addr = phys_addr - res->phys_start + res->bus_start;if (bus_addr >= res->bus_start && - bus_addr < res->bus_start + res->size) { + (bus_addr - res->bus_start) < res->size) { *ba = bus_addr;return 0 ; } --
For some reason, this patch did not show up on patchwork for sometime and it lost my 'Reviewed-by' tag. Here it is:
PATCH 1/1 pci: fix address range check in __pci_hose_phys_to_bus()
In reply to Marcel ZiswilerQuoted 12 lines · Marcel Ziswiler
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both
0x80000000leading to the following messages:Apalis TK1 # tftpboot $loadaddr
test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address:0x80408000
Loading:pci_hose_phys_to_bus: invalid physical address
Quoted 3 lines
This patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in
__pci_hose_bus_to_phys().
PATCH 1/1 pci: fix address range check in __pci_hose_phys_to_bus()
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Marcel Ziswiler
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both
0x80000000leading to the following messages:Apalis TK1 # tftpboot $loadaddr
test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address:0x80408000
Loading:pci_hose_phys_to_bus: invalid physical address
Quoted 6 lines
Quoted 3 lines
This patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in
__pci_hose_bus_to_phys().Reviewed-by Stephen Warren <[email protected]>
Quoted 16 lines · Marcel Ziswiler
The address range check may overflow if the memory region is located at the top of the 32-bit address space. This can e.g. be seen on TK1 if using the E1000 gigabit Ethernet driver where start and size are both
0x80000000leading to the following messages:Apalis TK1 # tftpboot $loadaddr
test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2 Filename 'test_file'.
Load address:0x80408000
Loading:pci_hose_phys_to_bus: invalid physical addressThis patch fixes this by changing the order of the addition vs. subtraction in the range check just like already done in
__pci_hose_bus_to_phys().
Quoted 5 lines
Reported-by Ivan Mercier <[email protected]>Signed-off-by Marcel Ziswiler <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Stephen Warren <[email protected]>Acked-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151123/17b09a21/attachment.sig>