mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(esp_tee): ensure hal assert is enabled for tee builds
This commit is contained in:
@@ -57,6 +57,14 @@ extern "C" {
|
|||||||
#error "CONFIG_SECURE_TEE_DROM_SIZE must be a multiple of SOC_MMU_PAGE_SIZE"
|
#error "CONFIG_SECURE_TEE_DROM_SIZE must be a multiple of SOC_MMU_PAGE_SIZE"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* With HAL assertions disabled (level 0), a failed HAL_ASSERT() expands to
|
||||||
|
* __builtin_unreachable(): the compiler then optimizes assuming the asserted
|
||||||
|
* preconditions always hold, turning any unvalidated HAL input into undefined
|
||||||
|
* behavior. The TEE must never be built this way. */
|
||||||
|
#if CONFIG_SECURE_ENABLE_TEE && (CONFIG_HAL_DEFAULT_ASSERTION_LEVEL < 1)
|
||||||
|
#error "ESP-TEE requires HAL assertions (CONFIG_HAL_DEFAULT_ASSERTION_LEVEL >= 1)"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TEE Secure Storage partition label and NVS namespace */
|
/* TEE Secure Storage partition label and NVS namespace */
|
||||||
#define ESP_TEE_SEC_STG_PART_LABEL "secure_storage"
|
#define ESP_TEE_SEC_STG_PART_LABEL "secure_storage"
|
||||||
#define ESP_TEE_SEC_STG_NVS_NAMESPACE "tee_sec_stg_ns"
|
#define ESP_TEE_SEC_STG_NVS_NAMESPACE "tee_sec_stg_ns"
|
||||||
|
|||||||
@@ -275,11 +275,6 @@ esp_err_t _ss_esp_tee_sec_storage_ecdsa_sign_pbkdf2(const esp_tee_sec_storage_pb
|
|||||||
|
|
||||||
/* ---------------------------------------------- MMU HAL ------------------------------------------------- */
|
/* ---------------------------------------------- MMU HAL ------------------------------------------------- */
|
||||||
|
|
||||||
/* Gates for REE-supplied external-flash address ranges. The HAL maps whole pages,
|
|
||||||
* so validate the page-rounded span it will actually touch (not the raw byte len)
|
|
||||||
* and require page-aligned addresses, so a sub-page or misaligned request cannot
|
|
||||||
* smuggle in an adjacent TEE page. mmu_hal_check_valid_ext_vaddr_region() must be
|
|
||||||
* enforced HERE, at the boundary: it rejects out-of-window (aliased) vaddrs. */
|
|
||||||
static bool tee_ree_ext_vaddr_ok(uint32_t mmu_id, uint32_t vaddr, uint32_t len)
|
static bool tee_ree_ext_vaddr_ok(uint32_t mmu_id, uint32_t vaddr, uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t page = mmu_hal_pages_to_bytes(mmu_id, 1);
|
uint32_t page = mmu_hal_pages_to_bytes(mmu_id, 1);
|
||||||
@@ -332,8 +327,6 @@ void _ss_mmu_hal_unmap_region(uint32_t mmu_id, uint32_t vaddr, uint32_t len)
|
|||||||
|
|
||||||
bool _ss_mmu_hal_vaddr_to_paddr(uint32_t mmu_id, uint32_t vaddr, uint32_t *out_paddr, mmu_target_t *out_target)
|
bool _ss_mmu_hal_vaddr_to_paddr(uint32_t mmu_id, uint32_t vaddr, uint32_t *out_paddr, mmu_target_t *out_target)
|
||||||
{
|
{
|
||||||
/* Same aliasing gate as map/unmap; translation itself is page-granular and
|
|
||||||
* vaddr need not be aligned, so validate the page containing it. */
|
|
||||||
uint32_t page = mmu_hal_pages_to_bytes(mmu_id, 1);
|
uint32_t page = mmu_hal_pages_to_bytes(mmu_id, 1);
|
||||||
bool valid_addr = (tee_ree_ext_vaddr_ok(mmu_id, ESP_ALIGN_DOWN(vaddr, page), 1) &&
|
bool valid_addr = (tee_ree_ext_vaddr_ok(mmu_id, ESP_ALIGN_DOWN(vaddr, page), 1) &&
|
||||||
esp_tee_buf_in_ree(out_paddr, sizeof(uint32_t)) &&
|
esp_tee_buf_in_ree(out_paddr, sizeof(uint32_t)) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user