summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mvebu
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-01-14 14:31:37 +0100
committerStefan Roese <sr@denx.de>2022-01-20 11:35:29 +0100
commit66f874855cc6e750e979a9e08bb96d0da38d534f (patch)
treec1327109479a042c71f925013e7223f158c6234f /arch/arm/mach-mvebu
parent4364071362b5d2dd7949f0734e96ab9d18ce6322 (diff)
arm: mvebu: Check that kwbimage offset and blocksize are valid
There are certain restrictions for kwbimage offset and blocksize. Validate them. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'arch/arm/mach-mvebu')
-rw-r--r--arch/arm/mach-mvebu/spl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index aada83f190..47b64c1463 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -162,6 +162,18 @@ 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 (0x%08x) in kwbimage\n",
+ spl_image->offset);
+ return -EINVAL;
+ }
+
+ if (mhdr->blocksize <= 4 || mhdr->blocksize % 4 != 0) {
+ printf("ERROR: Wrong blocksize (0x%08x) in kwbimage\n",
+ mhdr->blocksize);
+ return -EINVAL;
+ }
+
spl_image->size = mhdr->blocksize;
spl_image->entry_point = mhdr->execaddr;
spl_image->load_addr = mhdr->destaddr;