From 7bbe2e775d921983c4fd3197aea2d9afc2b42c71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Sat, 21 Jan 2023 13:59:20 +0100 Subject: [PATCH] cmd: mvebu/bubt: Fix parsing SATA kwbimage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Despite the official specification, Marvell BootROM does not interpret srcaddr from SATA image as number of sectors the beginning of the hard drive, but as number of sectors relative to the main header. Reject invalid and accept valid SATA images. Fixes: 433dcd954580 ("cmd: mvebu/bubt: Check for A38x image data checksum") Signed-off-by: Pali Rohár --- cmd/mvebu/bubt.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index 6bb84da03e..2bcdf145f6 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -738,14 +738,8 @@ static int check_image_header(void) offset = le32_to_cpu(hdr->srcaddr); size = le32_to_cpu(hdr->blocksize); - if (hdr->blockid == 0x78) { /* SATA id */ - if (offset < 1) { - printf("Error: Bad A38x image srcaddr.\n"); - return -ENOEXEC; - } - offset -= 1; + if (hdr->blockid == 0x78) /* SATA id */ offset *= 512; - } if (offset % 4 != 0 || size < 4 || size % 4 != 0) { printf("Error: Bad A38x image blocksize.\n"); -- 2.39.5