kwbimage: Fix out of bounds access
PATCH 1/1 kwbimage: Fix out of bounds access
The kwbimage format is reading beyond its header structure if it misdetects a Xilinx Zynq image and tries to read it. Fix it by sanity checking that the header we want to read fits inside our file size.
--- tools/kwbimage.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/kwbimage.c +4 -0
@@ -1616,6 +1616,10 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) {uint8_t checksum; +size_t header_size =kwbimage_header_size (ptr); + +if (header_size > image_size) +return -FDT_ERR_BADSTRUCTURE ;if (!main_hdr_checksum_ok (ptr))return -FDT_ERR_BADSTRUCTURE ;
Signature · 1 line
2.12.3
PATCH 1/1 kwbimage: Fix out of bounds access
Quoted 16 lines · Alexander Graf
The kwbimage format is reading beyond its header structure if it misdetects a Xilinx Zynq image and tries to read it. Fix it by sanity checking that the header we want to read fits inside our file size.
Signed-off-by Alexander Graf <[email protected]>--- tools/kwbimage.c | 4 ++++ 1 file changed, 4 insertions(+)tools/kwbimage.c +0
-0
tools/kwbimage.c static int kwbimage_verify_header(unsigned char *ptr, int image_size, · line 1625
Quoted 10 lines
tools/kwbimage.c +4
-0@@ -1616,6 +1616,10 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) {uint8_t checksum; +size_t header_size =kwbimage_header_size (ptr); + +if (header_size > image_size) +return -FDT_ERR_BADSTRUCTURE ;if (!main_hdr_checksum_ok (ptr))return -FDT_ERR_BADSTRUCTURE ;
Thanks,
Michal
PATCH 1/1 kwbimage: Fix out of bounds access
In reply to Alexander GrafQuoted 16 lines · Alexander Graf
The kwbimage format is reading beyond its header structure if it misdetects a Xilinx Zynq image and tries to read it. Fix it by sanity checking that the header we want to read fits inside our file size.
Signed-off-by Alexander Graf <[email protected]>--- tools/kwbimage.c | 4 ++++ 1 file changed, 4 insertions(+)tools/kwbimage.c +0
-0
tools/kwbimage.c static int kwbimage_verify_header(unsigned char *ptr, int image_size, · line 1625
Quoted 10 lines
tools/kwbimage.c +4
-0@@ -1616,6 +1616,10 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) {uint8_t checksum; +size_t header_size =kwbimage_header_size (ptr); + +if (header_size > image_size) +return -FDT_ERR_BADSTRUCTURE ;if (!main_hdr_checksum_ok (ptr))return -FDT_ERR_BADSTRUCTURE ;
Thanks,
Stefan
PATCH 1/1 kwbimage: Fix out of bounds access
In reply to Alexander GrafQuoted 16 lines · Alexander Graf
The kwbimage format is reading beyond its header structure if it misdetects a Xilinx Zynq image and tries to read it. Fix it by sanity checking that the header we want to read fits inside our file size.
Signed-off-by Alexander Graf <[email protected]>--- tools/kwbimage.c | 4 ++++ 1 file changed, 4 insertions(+)tools/kwbimage.c +0
-0
tools/kwbimage.c static int kwbimage_verify_header(unsigned char *ptr, int image_size, · line 1625
Quoted 10 lines
tools/kwbimage.c +4
-0@@ -1616,6 +1616,10 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) {uint8_t checksum; +size_t header_size =kwbimage_header_size (ptr); + +if (header_size > image_size) +return -FDT_ERR_BADSTRUCTURE ;if (!main_hdr_checksum_ok (ptr))return -FDT_ERR_BADSTRUCTURE ;
Applied to u-boot-marvell/master.
Thanks,
Stefan