xen: arm: correct off-by-one error in consider_modules
PATCH 1/1 xen: arm: correct off-by-one error in consider_modules
By iterating up to <= mi->nr_mods we are running off the end of the boot modules, but more importantly it causes us to then skip the first FDT reserved region, meaning we might clobber it.
---
For 4.5: I think this bug fix should go in, it fixes a real issue and is low risk.
I'll also add to my list of things to consider for backport to 4.4.
--- xen/arch/arm/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/setup.c +1 -1
@@ -286,7 +286,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e,return 0 ;/* First check the boot modules */ -for ( i = first_mod; i <= mi->nr_mods; i++ ) +for ( i = first_mod; i < mi->nr_mods; i++ ) {paddr_t mod_s = mi->module[i].start;paddr_t mod_e = mod_s + mi->module[i].size;
Signature · 1 line
2.1.3
Hi Ian,
Quoted 3 lines · Ian Campbell
By iterating up to <=
mi->nr_modswe are running off the end of the boot modules, but more importantly it causes us to then skip the first FDT reserved region, meaning we might clobber it.
Oops. Good catch!
OOI, how did you find it?
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>
Quoted 3 lines
---
For 4.5: I think this bug fix should go in, it fixes a real issue and is low risk.
Agreed.
Quoted 1 line
I'll also add to my list of things to consider for backport to 4.4.
Ditto.
Regards,
Signature · 1 line
Julien Grall
Quoted 10 lines · Julien Grall
Hi Ian,
Quoted 3 lines · Ian Campbell
By iterating up to <=
mi->nr_modswe are running off the end of the boot modules, but more importantly it causes us to then skip the first FDT reserved region, meaning we might clobber it.Oops. Good catch!
OOI, how did you find it?
U-boot on Jetson was locating the PSCI handling code at the top of RAM and reserving it in the DT, but Xen was still relocating itself over it, causing secondary CPU bringup to hang the board.
(This is an experimental u-boot, so it doesn't actually enforce the security of the PSCI region yet, if it did I'd have expected a fault on relocation instead of a hang on CPU up).
Ian.
Quoted 7 lines · Julien Grall
Hi Ian,
Quoted 3 lines · Ian Campbell
By iterating up to <=
mi->nr_modswe are running off the end of the boot modules, but more importantly it causes us to then skip the first FDT reserved region, meaning we might clobber it.
Quoted 11 lines
Oops. Good catch!
OOI, how did you find it?
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>Reviewed-by Julien Grall <[email protected]>Quoted 3 lines
---
For 4.5: I think this bug fix should go in, it fixes a real issue and is low risk.
Quoted 11 lines
Agreed.
Quoted 1 line
I'll also add to my list of things to consider for backport to 4.4.
Ditto.
Regards,
Signature · 1 line
Julien Grall
Ian Campbell
AppliedQuoted 14 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Julien Grall
Hi Ian,
Quoted 3 lines · Ian Campbell
By iterating up to <=
mi->nr_modswe are running off the end of the boot modules, but more importantly it causes us to then skip the first FDT reserved region, meaning we might clobber it.Oops. Good catch!
OOI, how did you find it?
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>
Quoted 7 lines
Quoted 5 lines
Reviewed-by Julien Grall <[email protected]>Quoted 3 lines
---
For 4.5: I think this bug fix should go in, it fixes a real issue and is low risk.Release-Acked-by Konrad Rzeszutek Wilk <[email protected]>
Applied, thanks.
Quoted 10 lines · Ian Campbell
By iterating up to <=
mi->nr_modswe are running off the end of the boot modules, but more importantly it causes us to then skip the first FDT reserved region, meaning we might clobber it.Signed-off-by Ian Campbell <[email protected]>---
For 4.5: I think this bug fix should go in, it fixes a real issue and is low risk.I'll also add to my list of things to consider for backport to 4.4.
In 4.4 nr_mods was, confusingly, the index of the highest mod present, not the nr. This changed in e73b7d6619c8 "xen: arm: store per-boot module type instead of relying on index", which is how this off by one came to be.
e73b7d6619c8 is not in 4.4, consequently I don't think it would be correct to backport this either.
Ian.
Quoted 17 lines
--- xen/arch/arm/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/setup.c +1
-1@@ -286,7 +286,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e,return 0 ;/* First check the boot modules */ -for ( i = first_mod; i <= mi->nr_mods; i++ ) +for ( i = first_mod; i < mi->nr_mods; i++ ) {paddr_t mod_s = mi->module[i].start;paddr_t mod_e = mod_s + mi->module[i].size;