From: Pali Rohár <[email protected]>

There are certain restrictions for kwbimage offset and blocksize.
Validate them.

Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
---
 arch/arm/mach-mvebu/spl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 73c4b9af3e..71994e44f1 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -163,6 +163,16 @@ int spl_parse_board_header(struct spl_image_info 
*spl_image,
                spl_image->offset *= 512;
 #endif
 
+       if (spl_image->offset % 4 != 0) {
+               printf("ERROR: Wrong srcaddr in kwbimage\n");
+               return -EINVAL;
+       }
+
+       if (mhdr->blocksize <= 4 || mhdr->blocksize % 4 != 0) {
+               printf("ERROR: Wrong blocksize in kwbimage\n");
+               return -EINVAL;
+       }
+
        spl_image->size = mhdr->blocksize;
        spl_image->entry_point = mhdr->execaddr;
        spl_image->load_addr = mhdr->destaddr;
-- 
2.32.0

Reply via email to