pseries: Fix array overrun bug in PCI code
PATCH 1/1 pseries: Fix array overrun bug in PCI code
spapr_populate_pci_devices() containd a loop with PCI_NUM_REGIONS (7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that.
--- hw/spapr_pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/spapr_pci.c +1 -1
@@ -454,7 +454,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb, reg[0 ].size =0 ; n =0 ; -for (i =0 ; i <PCI_NUM_REGIONS ; ++i) { +for (i =0 ; i <ARRAY_SIZE (bars); ++i) {if (0 == dev->io_regions[i].size) {continue ; }
Signature · 1 line
1.7.7.3
Quoted 6 lines · David Gibson
spapr_populate_pci_devices()containd a loop withPCI_NUM_REGIONS(7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that.Signed-off-by David Gibson <[email protected]>
As a bugfix for a bad memory access, this is definitely for 1.0
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 9 lines · David Gibson
Quoted 6 lines · David Gibson
spapr_populate_pci_devices()containd a loop withPCI_NUM_REGIONS(7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that.Signed-off-by David Gibson <[email protected]>As a bugfix for a bad memory access, this is definitely for 1.0
Now applied. Indeed it would probably have been better done before the release.
Cheers
Quoted 7 lines · andrzej zaborowski
Quoted 6 lines · David Gibson
Quoted 5 lines · David Gibson
spapr_populate_pci_devices()containd a loop withPCI_NUM_REGIONS(7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by David Gibson <[email protected]>As a bugfix for a bad memory access, this is definitely for 1.0
Now applied. Indeed it would probably have been better done before the release.
Well, that's why we aligned to have 1.0.1 around christmas - because there will be more issues exposed soon, I'm fairly sure :)
Thanks for applying btw.
Alex
Alexander Graf
AppliedQuoted 6 lines · David Gibson
spapr_populate_pci_devices()containd a loop withPCI_NUM_REGIONS(7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that.Signed-off-by David Gibson <[email protected]>
Thanks, applied to ppc-next and queued for 1.0.
Alex
Quoted 20 lines
---
hw/spapr_pci.c| 2 +-1 files changed, 1 insertions(+), 1 deletions(-)hw/spapr_pci.c +1
-1@@ -454,7 +454,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb, reg[0 ].size =0 ; n =0 ; -for (i =0 ; i <PCI_NUM_REGIONS ; ++i) { +for (i =0 ; i <ARRAY_SIZE (bars); ++i) {if (0 == dev->io_regions[i].size) {continue ; }Signature · 1 line
1.7.7.3
Quoted 11 lines · Alexander Graf
Quoted 6 lines · David Gibson
spapr_populate_pci_devices()containd a loop withPCI_NUM_REGIONS(7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that.Signed-off-by David Gibson <[email protected]>Thanks, applied to ppc-next and queued for 1.0.
Call me stupid. Only queued for 1.0 of course.
Alex