* [PATCH] ARM: bootm: Add lower bound check of kernel in SDRAM
@ 2020-10-27 6:17 Alexander Shiyan
2020-10-28 8:24 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shiyan @ 2020-10-27 6:17 UTC (permalink / raw)
To: barebox
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 <shc_work@mail.ru>
---
arch/arm/lib32/bootm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index ad807fb1d..28a645a9d 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -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);
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ARM: bootm: Add lower bound check of kernel in SDRAM
2020-10-27 6:17 [PATCH] ARM: bootm: Add lower bound check of kernel in SDRAM Alexander Shiyan
@ 2020-10-28 8:24 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-10-28 8:24 UTC (permalink / raw)
To: Alexander Shiyan; +Cc: barebox
On Tue, Oct 27, 2020 at 09:17:54AM +0300, Alexander Shiyan wrote:
> 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 <shc_work@mail.ru>
> ---
> arch/arm/lib32/bootm.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
> index ad807fb1d..28a645a9d 100644
> --- a/arch/arm/lib32/bootm.c
> +++ b/arch/arm/lib32/bootm.c
> @@ -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);
> --
> 2.26.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-28 8:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 6:17 [PATCH] ARM: bootm: Add lower bound check of kernel in SDRAM Alexander Shiyan
2020-10-28 8:24 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox