mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] ARM: cpu: start: align uncompressed DTB size to 4 bytes
@ 2024-05-17  6:22 Ahmad Fatoum
  2024-05-17  6:22 ` [PATCH master 2/2] RISC-V: " Ahmad Fatoum
  2024-05-21  7:15 ` [PATCH master 1/2] ARM: cpu: " Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-05-17  6:22 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

KASAN reports that decompression exceeds the bounds of the allocation
and my DT size isn't 4-bytes aligned. Align the allocation size to fix
this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/cpu/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 6d0a7cfc6b04..2adc60fa8831 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -79,7 +79,7 @@ void *barebox_arm_boot_dtb(void)
 
 	pr_debug("%s: using compressed_dtb\n", __func__);
 
-	dtb = malloc(compressed_dtb->datalen_uncompressed);
+	dtb = malloc(ALIGN(compressed_dtb->datalen_uncompressed, 4));
 	if (!dtb)
 		return NULL;
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH master 2/2] RISC-V: start: align uncompressed DTB size to 4 bytes
  2024-05-17  6:22 [PATCH master 1/2] ARM: cpu: start: align uncompressed DTB size to 4 bytes Ahmad Fatoum
@ 2024-05-17  6:22 ` Ahmad Fatoum
  2024-05-21  7:15 ` [PATCH master 1/2] ARM: cpu: " Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-05-17  6:22 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

On ARM, I ran into a KASAN splat, because the uncompressed DT may not
have a 4-byte aligned size. This can affect RISC-V boards too, so import
the fix done there.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/riscv/boot/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/boot/start.c b/arch/riscv/boot/start.c
index 92991d0f6a84..d20526293bac 100644
--- a/arch/riscv/boot/start.c
+++ b/arch/riscv/boot/start.c
@@ -54,7 +54,7 @@ void *barebox_riscv_boot_dtb(void)
 
 	pr_debug("%s: using compressed_dtb\n", __func__);
 
-	dtb = malloc(compressed_dtb->datalen_uncompressed);
+	dtb = malloc(ALIGN(compressed_dtb->datalen_uncompressed, 4));
 	if (!dtb)
 		return NULL;
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master 1/2] ARM: cpu: start: align uncompressed DTB size to 4 bytes
  2024-05-17  6:22 [PATCH master 1/2] ARM: cpu: start: align uncompressed DTB size to 4 bytes Ahmad Fatoum
  2024-05-17  6:22 ` [PATCH master 2/2] RISC-V: " Ahmad Fatoum
@ 2024-05-21  7:15 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-05-21  7:15 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Fri, 17 May 2024 08:22:24 +0200, Ahmad Fatoum wrote:
> KASAN reports that decompression exceeds the bounds of the allocation
> and my DT size isn't 4-bytes aligned. Align the allocation size to fix
> this.
> 
> 

Applied, thanks!

[1/2] ARM: cpu: start: align uncompressed DTB size to 4 bytes
      https://git.pengutronix.de/cgit/barebox/commit/?id=ce38eef3c056 (link may not be stable)
[2/2] RISC-V: start: align uncompressed DTB size to 4 bytes
      https://git.pengutronix.de/cgit/barebox/commit/?id=249164bc555f (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-21  7:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-17  6:22 [PATCH master 1/2] ARM: cpu: start: align uncompressed DTB size to 4 bytes Ahmad Fatoum
2024-05-17  6:22 ` [PATCH master 2/2] RISC-V: " Ahmad Fatoum
2024-05-21  7:15 ` [PATCH master 1/2] ARM: cpu: " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox