Skip to content

Commit b2cdc06

Browse files
committed
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 dbbe2cf commit b2cdc06

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
@@ -701,12 +701,16 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
701701
#endif
702702
}
703703
uint32_t *dest = (uint32_t *)load_addr;
704-
#endif
704+
#endif // BOOTLOADER_BUILD
705705

706706
const uint32_t *src = data;
707707

708708
#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
709-
if (segment == 0) {
709+
// Case I: Bootloader verifying application
710+
// Case II: Bootloader verifying bootloader
711+
// Anti-rollback check should handle only Case I from above.
712+
if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
713+
ESP_LOGD(TAG, "additional anti-rollback check 0x%"PRIx32, data_addr);
710714
// The esp_app_desc_t structure is located in DROM and is always in segment #0.
711715
size_t len = process_esp_app_desc_data(src, sha_handle, checksum, metadata);
712716
data_len -= len;

0 commit comments

Comments
 (0)