Skip to content

Commit 3adcc9d

Browse files
committed
aboot: Prevent booting into lk2nd from mmc repeatly
1 parent 7f7306b commit 3adcc9d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/aboot/aboot.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,16 @@ int boot_linux_from_mmc(void)
16721672
return -1;
16731673
}
16741674

1675+
/* If lk2nd is installed on the mmc's boot partition,
1676+
* the device would repeat booting into lk2nd forever.
1677+
* Prevent this to happen.
1678+
*/
1679+
char *hdr_cmdline_lk2nd_pos = strstr((const char *)hdr->cmdline, "lk2nd");
1680+
if (hdr_cmdline_lk2nd_pos && *(hdr_cmdline_lk2nd_pos + strlen("lk2nd")) == '\0') {
1681+
dprintf(CRITICAL, "ERROR: lk2nd detected on partition %s\n", ptn_name);
1682+
return ERR_REPEAT_BOOT_LK2ND;
1683+
}
1684+
16751685
if (memcmp(hdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
16761686
dprintf(CRITICAL, "ERROR: Invalid boot image header\n");
16771687
return ERR_INVALID_BOOT_MAGIC;
@@ -5693,6 +5703,7 @@ void aboot_init(const struct app_descriptor *app)
56935703
case ERR_DT_PARSE:
56945704
case ERR_ABOOT_ADDR_OVERLAP:
56955705
case ERR_INVALID_BOOT_MAGIC:
5706+
case ERR_REPEAT_BOOT_LK2ND:
56965707
if(partition_multislot_is_supported())
56975708
{
56985709
/*

app/aboot/bootimg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,6 @@ enum
235235
ERR_DECOMPRESSION,
236236
ERR_DT_PARSE,
237237
ERR_BOOT_SIGNATURE_MISMATCH,
238+
ERR_REPEAT_BOOT_LK2ND,
238239
};
239240
#endif

0 commit comments

Comments
 (0)