Skip to content

Commit 53fe6a6

Browse files
committed
MA-24310 Fix bug: imx_signer failed to sign Android bootloader on i.MX 8m
Android with i.MX 8m platform used HABv4 to verify the signed bootloader. To make sure all of components in bootloader image be signed, we enabled a optional function on Android bootloader: Add optional FIT FDT signature (CVE-2023-39902). But this tool failed to sign Android bootloader because incorrect CSF generated. To fix this issue, the optional IVT should use a local image table to generate the CSF file. Signed-off-by: Maximus <maximus.sun@nxp.com>
1 parent 7c7812a commit 53fe6a6

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/imx_signer.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,23 +1438,24 @@ static int process_ivt_image(unsigned long off, uint8_t *infile_buf,
14381438
ivt_t *ivt = NULL;
14391439
int err = -E_FAILURE;
14401440
boot_data_t *boot = NULL;
1441+
image_block_t image_ivt[NUM_IMGS] = {0};
14411442

14421443
/* Compare the entry address with self address. For kernel images
14431444
* IVT is placed at the end of the image file. In this case the load
14441445
* address is offset(which is image size) minus the difference between
14451446
* self (where the ivt is ) and entry (the beginning of the image).
14461447
* This difference in case of kernel images is 0. For other images like
14471448
* FDT image the offset is non zero*/
1448-
g_images[0].valid = true;
1449+
image_ivt[0].valid = true;
14491450
ivt = (ivt_t *)(infile_buf + off);
14501451

1451-
g_images[0].load_addr = (ivt->self_addr > ivt->entry)
1452+
image_ivt[0].load_addr = (ivt->self_addr > ivt->entry)
14521453
? ivt->entry
14531454
: ivt->self_addr;
1454-
g_images[0].offset = (ivt->self_addr > ivt->entry)
1455+
image_ivt[0].offset = (ivt->self_addr > ivt->entry)
14551456
? (off - (ivt->self_addr - ivt->entry))
14561457
: off;
1457-
g_images[0].size = (ivt->self_addr > ivt->entry)
1458+
image_ivt[0].size = (ivt->self_addr > ivt->entry)
14581459
? (ivt->csf_addr - ivt->entry)
14591460
: (ivt->csf_addr - ivt->self_addr);
14601461
csf_offset = (ivt->csf_addr - ivt->self_addr) + off;
@@ -1469,12 +1470,13 @@ static int process_ivt_image(unsigned long off, uint8_t *infile_buf,
14691470
}
14701471
}
14711472

1472-
DEBUG("Image[%d] addr 0x%08lx\n",0, g_images[0].load_addr);
1473-
DEBUG("Image[%d] offset 0x%08lx\n",0, g_images[0].offset);
1474-
DEBUG("Image[%d] size 0x%08lx\n",0, g_images[0].size);
1473+
DEBUG("Image[%d] addr 0x%08lx\n",0, image_ivt[0].load_addr);
1474+
DEBUG("Image[%d] offset 0x%08lx\n",0, image_ivt[0].offset);
1475+
DEBUG("Image[%d] size 0x%08lx\n",0, image_ivt[0].size);
14751476
DEBUG("Image[%d] csf_offset 0x%08x\n",0, csf_offset);
1477+
memcpy(g_images, image_ivt, sizeof(image_block_t));
14761478

1477-
err = create_csf_file_v1(g_images, loop, ofname);
1479+
err = create_csf_file_v1(image_ivt, loop, ofname);
14781480
if (err) {
14791481
errno = EFAULT;
14801482
fprintf(stderr, "ERROR: Couldn't create csf txt file %s\n", strerror(EFAULT));

0 commit comments

Comments
 (0)