Skip to content

Commit 7d0df74

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

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/aboot/aboot.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,15 @@ 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+
if (strstr((const char *)hdr->cmdline, "lk2nd")) {
1680+
dprintf(CRITICAL, "ERROR: lk2nd detected on partition %s\n", ptn_name);
1681+
return ERR_REPEAT_BOOT_LK2ND;
1682+
}
1683+
16751684
if (memcmp(hdr->magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
16761685
dprintf(CRITICAL, "ERROR: Invalid boot image header\n");
16771686
return ERR_INVALID_BOOT_MAGIC;
@@ -5693,6 +5702,7 @@ void aboot_init(const struct app_descriptor *app)
56935702
case ERR_DT_PARSE:
56945703
case ERR_ABOOT_ADDR_OVERLAP:
56955704
case ERR_INVALID_BOOT_MAGIC:
5705+
case ERR_REPEAT_BOOT_LK2ND:
56965706
if(partition_multislot_is_supported())
56975707
{
56985708
/*

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)