Skip to contentSkip to conversation

tools: kwbimage: Verify maximal kwbimage header size

PATCH In review Pali Rohár 2 participants 3 messages Sep 18, 2022 – Oct 6, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: kwbimage: Verify maximal kwbimage header size

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

---
 tools/kwbimage.c | 3 +++
 1 file changed, 3 insertions(+)
tools/kwbimage.c +3 -0
index 94b768539222..6abb9f2d5c01 100644
@@ -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;
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Pali Rohár

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

Thanks,
Stefan

Quoted 9 lines
---
  tools/kwbimage.c | 3 +++
  1 file changed, 3 insertions(+)
tools/kwbimage.c +0 -0
index 94b768539222..6abb9f2d5c01 100644

tools/kwbimage.c static int kwbimage_verify_header(unsigned char *ptr, int image_size, · line 1977

Quoted 9 lines
tools/kwbimage.c +3 -0
@@ -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;
 

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#2 lore raw
In reply to Pali Rohár
Quoted 3 lines · Pali Rohár

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

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 9 lines
---
  tools/kwbimage.c | 3 +++
  1 file changed, 3 insertions(+)
tools/kwbimage.c +0 -0
index 94b768539222..6abb9f2d5c01 100644

tools/kwbimage.c static int kwbimage_verify_header(unsigned char *ptr, int image_size, · line 1977

Quoted 9 lines
tools/kwbimage.c +3 -0
@@ -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;
 

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]