Skip to content

Commit c33b9e1

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 f460cc7 commit c33b9e1

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
@@ -688,12 +688,16 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
688688
#endif
689689
}
690690
uint32_t *dest = (uint32_t *)load_addr;
691-
#endif
691+
#endif // BOOTLOADER_BUILD
692692

693693
const uint32_t *src = data;
694694

695695
#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
696-
if (segment == 0) {
696+
// Case I: Bootloader verifying application
697+
// Case II: Bootloader verifying bootloader
698+
// Anti-rollback check should handle only Case I from above.
699+
if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
700+
ESP_LOGD(TAG, "additional anti-rollback check 0x%"PRIx32, data_addr);
697701
// The esp_app_desc_t structure is located in DROM and is always in segment #0.
698702
size_t len = process_esp_app_desc_data(src, sha_handle, checksum, metadata);
699703
data_len -= len;

0 commit comments

Comments
 (0)