[PATCH] tools: kwbimage: Verify maximal kwbimage header size

Pali Rohár pali at kernel.org
Sun Sep 18 18:39:18 CEST 2022


BootROM loads kwbimage header to L2-SRAM and BootROM reserve only 192 kB for it.

Signed-off-by: Pali Rohár <pali at kernel.org>
---
 tools/kwbimage.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 94b768539222..6abb9f2d5c01 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1969,6 +1969,9 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
 	uint32_t size;
 	uint8_t csum;
 
+	if (header_size > 192*1024)
+		return -FDT_ERR_BADSTRUCTURE;
+
 	if (header_size > image_size)
 		return -FDT_ERR_BADSTRUCTURE;
 
-- 
2.20.1



More information about the U-Boot mailing list