Skip to content

Commit 1620858

Browse files
mahavirjKonstantinKondrashov
authored andcommitted
fix(bootloader_support): check the secure version only for app image
Secure version in the image header is only available for the application image. However, for certain security workflows, bootloader verifies itself (own image) and hence the secure version check during that must be avoided. Regression introduced in recent commit-id: 3305cb4 Tested that both secure boot and flash-enc workflows work correctly with the anti-rollback scenario.
1 parent f274370 commit 1620858

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/bootloader_support/src/esp_image_format.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,12 +684,16 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
684684
#endif
685685
}
686686
uint32_t *dest = (uint32_t *)load_addr;
687-
#endif
687+
#endif // BOOTLOADER_BUILD
688688

689689
const uint32_t *src = data;
690690

691691
#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
692-
if (segment == 0) {
692+
// Case I: Bootloader verifying application
693+
// Case II: Bootloader verifying bootloader
694+
// Anti-rollback check should handle only Case I from above.
695+
if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
696+
ESP_LOGD(TAG, "additional anti-rollback check 0x%"PRIx32, data_addr);
693697
// The esp_app_desc_t structure is located in DROM and is always in segment #0.
694698
size_t len = process_esp_app_desc_data(src, sha_handle, checksum, metadata);
695699
data_len -= len;

0 commit comments

Comments
 (0)