> Runtime relocation entries are not guaranteed to be sorted by target
> address. This was observed with GNU ld 2.42 when linking qemu-x86 using
> --emit-relocs and -pie: after an unrelated image-layout change, .rel.dyn
> contained 450 address decreases. The old code skipped relocation of
> mem_malloc_brk in sbrk(), causing allocation to fail and log_init() to
> abort boot.
>
> The ordering check was added as a cheap corruption guard because .bss
> overlays __rel_dyn_start and may overwrite relocation entries before
> relocation. Replace it with lower and upper image-bound checks. Together
> with the existing type and target checks, these reject most corrupted
> entries without requiring sorted input. A corrupted entry whose location
> and target both happen to be in range may still be applied; the ordering
> check likewise could not reject corruption that preserved increasing
> addresses.
>
> Apply the same correction to the 32-bit and 64-bit paths.
>
> Fixes: b50b1633c022 ("x86: Add support for 64-bit relocation")
> Fixes: 62f7970a5a06 ("x86: Add error checking to x86 relocation code")
> Signed-off-by: Jerome Forissier <[email protected]>
> ---
>  arch/x86/lib/relocate.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)

Applied to u-boot-net branch for-main [1], thanks!

[1] 
https://git.u-boot-project.org/u-boot/custodians/u-boot-net/-/commits/for-main

[1/1] x86: Handle unordered runtime relocations
      commit: 4c08266b7a6654f731167e615f00e0676750497c

Best regards,
-- 
Jerome Forissier <[email protected]>

Reply via email to