ARM: bootm: Add lower bound check of kernel in SDRAM
PATCH 1/1 ARM: bootm: Add lower bound check of kernel in SDRAM
In get_kernel_addresses(), we add the lower bound check of kernel position. Kernel address cannot be lower than SDRAM start.
Signed-off-by Alexander Shiyan <[email protected]>
--- arch/arm/lib32/bootm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/lib32/bootm.c +3 -2
@@ -114,10 +114,11 @@ static int get_kernel_addresses(size_t image_size, kaddr = mem_start + image_decomp_size;/* -* Make sure we do not place the image past the end of the +* Make sure we do not place the image outside of the * available memory. */ -if (kaddr + image_size + spacing >= mem_end) +if (((kaddr + image_size + spacing) > mem_end) && + ((mem_end - image_size - spacing) >= mem_start)) kaddr = mem_end - image_size - spacing; *load_address =PAGE_ALIGN_DOWN (kaddr);
Signature · 7 lines
2.26.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 7 lines · Alexander Shiyan
In
get_kernel_addresses(), we add the lower bound check of kernel position. Kernel address cannot be lower than SDRAM start.Signed-off-by Alexander Shiyan <[email protected]>--- arch/arm/lib32/bootm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
Quoted 28 lines
arch/arm/lib32/bootm.c +3
-2@@ -114,10 +114,11 @@ static int get_kernel_addresses(size_t image_size, kaddr = mem_start + image_decomp_size;/* -* Make sure we do not place the image past the end of the +* Make sure we do not place the image outside of the * available memory. */ -if (kaddr + image_size + spacing >= mem_end) +if (((kaddr + image_size + spacing) > mem_end) && + ((mem_end - image_size - spacing) >= mem_start)) kaddr = mem_end - image_size - spacing; *load_address =PAGE_ALIGN_DOWN (kaddr);Signature · 7 lines
2.26.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox