Commit Graph

197 Commits

Author SHA1 Message Date
Jiang Jiang Jian
27892e5e12 Merge branch 'fix/tee_reentrant_svc_and_non_det_sign_v6.1' into 'release/v6.1'
feat(esp_tee): Backports to v6.1

See merge request espressif/esp-idf!52291
2026-09-04 23:17:06 +08:00
Jiang Jiang Jian
6d6facef39 Merge branch 'stub_bins_for_more_targets_v6.1' into 'release/v6.1'
Increase OCD stub memory reservation from 8K to 12K and extend this feature to more targets (v6.1)

See merge request espressif/esp-idf!51534
2026-09-04 15:55:25 +08:00
Laukik Hase
4dd7ac7d73 change(esp_tee): Limit the TEE secure storage AEAD operation input buffer length 2026-09-04 10:20:21 +05:30
Laukik Hase
f8d0bae631 feat(esp_tee): Disable the MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS option for TEE build 2026-09-04 10:20:21 +05:30
Laukik Hase
4057fcda2d fix(esp_tee): Snapshot input arguments in TEE memory before secure service execution 2026-09-04 10:20:21 +05:30
Laukik Hase
02bf7ea021 change(esp_tee): Force non-deterministic ECDSA signing for TEE secure storage keys 2026-09-04 10:20:20 +05:30
Laukik Hase
bc6b8f7fa5 feat(esp_tee): Use CTR-DRBG for assisting random number generation in TEE
- For ESP-TEE, fault-assert in `esp_random()` if the RNG is held in a
  freeze state
2026-09-04 10:20:20 +05:30
Laukik Hase
f26c18bd5b fix(esp_tee): Reject re-entrant secure service calls from the REE 2026-09-04 10:20:19 +05:30
Alexey Gerenkov
d965c1bfcf Merge branch 'fix/newlib_builds_v6.1' into 'release/v6.1'
Fix: newlib compatibility with libraries built with picolibc headers (v6.1)

See merge request espressif/esp-idf!51523
2026-09-02 17:14:06 +08:00
Erhan Kurubas
ae0c69d9d8 feat(system): add OCD stub bin support for more targets
Add SOC_DEBUG_HAVE_OCD_STUB_BINS for esp32c5, esp32c61, esp32h4,
esp32h21, esp32p4, and esp32s31. Update TEE linker scripts with
correct esp_tee_app_config offsets for the 0x3000 stub reservation
2026-08-31 11:35:49 +08:00
Erhan Kurubas
0ee0684fd2 change(system): increase OCD stub memory reservation from 8K to 12K 2026-08-31 11:35:49 +08:00
Alexey Lapshin
84f3d0bd96 feat(libc): pass __PICOLIBC_ERRNO_FUNCTION to picolibc builds 2026-08-05 17:09:19 +07:00
Laukik Hase
548f85cb53 fix(esp_tee): Validate REE-supplied memory bounds (esp_tee_app_config) before use 2026-08-04 12:10:53 +05:30
Laukik Hase
773761abb8 fix(esp_tee): Validate the stack pointer at the privilege switch boundary 2026-08-04 12:10:52 +05:30
Laukik Hase
0809185c85 feat(esp_tee): Restrict REE access to TEE-owned secure storage keys 2026-07-17 18:14:38 +05:30
Laukik Hase
4861cd58c3 fix(esp_tee): Miscellaneous optimizations and fixes
Closes https://github.com/espressif/esp-idf/issues/18591
2026-07-17 18:14:38 +05:30
Ashish Sharma
5fb2dc6c74 fix(esp_tee): ensure hal assert is enabled for tee builds 2026-07-17 18:14:38 +05:30
Ashish Sharma
2fcdb164a1 fix(esp_tee): enforce MMU-map vaddr validity at the REE->TEE boundary 2026-07-17 18:14:37 +05:30
Ashish Sharma
c146cb5322 fix(esp_tee): fixes IV length check for TEE AEAD operations 2026-07-17 18:14:37 +05:30
Jiang Jiang Jian
947e534927 Merge branch 'fix/mmap_cache_flash_wr_v6.1' into 'release/v6.1'
fix(mmap): fixed mmap read data wrong when flash being erased/written and cache not disabled (v6.1)

See merge request espressif/esp-idf!50117
2026-07-17 10:30:14 +08:00
Xiao Xufeng
3e8389cc31 fix(mmap): fixed some API read wrong data via mmap when flash being erased/written while XIP on PSRAM
Before:

The cache won't be disabled when XIP on psram. But during flash
erasing/programming, read data will be courrupt.

When XIP in psram is enabled, the image is not mapped to the cache so
usually there will be no flash access. The only way to read from flash
is via the driver or use mmap. The driver has protection during erasing,
while th mmap region not.

Now:

Mmap APIs provide a flag to make mmap->unmap region mutually exclusive
to flash erase/programming when XIP from psram. SPI Flash write APIs
will benefit from this. When the flag is used, no concurrent access to
mapped region will happen while writing; otherwise the cache will be
disable to avoid data corruption.

Most ESP-IDF APIs calls mmap with this flag. As for users calling
mmap-like APIs directly, they can choose whether to enable this by a
flag.

Closes https://github.com/espressif/esp-idf/issues/14897
2026-07-15 18:57:08 +08:00
Ashish Sharma
8d8068aee3 fix(esp_tee): fix DS-lock leak, intr-matrix OOB, calloc overflow, attestation leak 2026-07-13 14:40:44 +08:00
Laukik Hase
87a5664883 ci(esp_tee): Fix tee_cli_app build failure due to heap size overflow
- Also fix the `unused variable` warning while builing the PSA
  AES tests with `tee_test_fw` app
2026-07-10 10:30:02 +05:30
Mahavir Jain
eda926af1c Merge branch 'fix/fix_esp_tee_failing_deterministic_ecdsa_sign_v6.1' into 'release/v6.1'
fix(esp_tee): release SHA held by HMAC after crypto peripheral reset (v6.1)

See merge request espressif/esp-idf!50317
2026-07-09 11:52:38 +05:30
Ashish Sharma
a3398cb629 fix(esp_tee): fixes double panic when ESP-TEE panics 2026-07-03 11:29:55 +08:00
Ashish Sharma
298d763003 fix(esp_tee): release SHA held by HMAC after crypto peripheral reset 2026-07-03 11:29:55 +08:00
Sudeep Mohanty
08dd7ce19e fix(components): initialize srcs variable to prevent scope leakage 2026-07-01 19:59:05 +08:00
Mahavir Jain
7a2bb09375 Merge branch 'fix/secure_boot_bootloader_ecdsa_range_gate_v6.1' into 'release/v6.1'
Add ECDSA signature bounds check in bootloader before Secure Boot verify (v6.1)

See merge request espressif/esp-idf!49632
2026-06-30 07:15:59 +05:30
Laukik Hase
e99233f202 fix(esp_tee): Add additional input validation checks for TEE service calls 2026-06-26 15:06:27 +05:30
Laukik Hase
081d27cbd2 fix(esp_tee): Avoid crypto peripherals reset with esp_restart() from REE
- Reset the crypto peripherals during TEE initialization
2026-06-26 15:06:13 +05:30
Laukik Hase
07970bd5df fix(esp_tee): Prevent TEE from dispatching the REE heap poisoning callback 2026-06-26 15:06:12 +05:30
harshal.patil
3e246a64a3 fix(esp_common/esp_fault): make ESP_FAULT_ASSERT survive optimization
ESP_FAULT_ASSERT(C) was silently deleted by the optimizer when C is a cached
flag/status already proven by a preceding `if (!C) return/goto`: the compiler
folds C to a constant and drops all three checks, removing the fault-injection
protection with no warning.
2026-06-18 17:00:42 +05:30
Mahavir Jain
a96553ed75 Merge branch 'fix/esp_tee_bbp_v6.1' into 'release/v6.1'
fix(esp_tee): Harden TEE secure services against REE manipulation (v6.1)

See merge request espressif/esp-idf!49368
2026-06-10 15:56:59 +05:30
Mahavir Jain
d460486ab4 Merge branch 'fix/ecdsa_ecc_hw_input_validation_v6.1' into 'release/v6.1'
Validate ECDSA signature range and harden ECC memory power-down (v6.1)

See merge request espressif/esp-idf!49427
2026-06-10 14:39:49 +05:30
Mahavir Jain
3664bd2d7e Merge branch 'fix/disable_secure_boot_v2_ecdsa_v6.1' into 'release/v6.1'
Fix/disable secure boot v2 ecdsa (v6.1)

See merge request espressif/esp-idf!49469
2026-06-10 14:39:06 +05:30
Laukik Hase
ba0f3f9872 fix(esp_tee): Harden the TEE secure services against REE manipulation
- `bootloader_flash_execute_command_common`: whitelist the flash command
   opcodes the REE actually uses; reject the rest
- `spi_flash_hal_* services`: a forged `host->driver` could hijack TEE
   control flow since the HAL dispatches through it, so swap
   `host->driver` to a TEE-rodata vtable around each HAL call
- Deny partition table and bootloader writes by default and permit
  bootloader writes only when explicitly enabled via
  `CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED` option
- Protect the TEE-assigned interrupt pin configuration against REE
- Validate nested DS context pointers in start/finish_sign and bound
  the result copy to the SoC max signature size
- Fix the stack usage in service dispatcher argument parsing
2026-06-10 12:05:47 +05:30
Aditya Patwardhan
4f2f37ca69 change(secure_boot): mark ECDSA based Secure Boot V2 as insecure on affected SoCs
ECDSA based Secure Boot V2 is not functional for certain input vectors on
ESP32-C5/C61/H2/P4 and on the preview targets ESP32-H4/H21. RSA based Secure
Boot V2 is the recommended scheme where the SoC supports it. This issue will be
fixed in a future hardware ECO revision; more details will be shared through the
hardware errata document.

A new hidden Kconfig option SECURE_BOOT_V2_ECDSA_INSECURE marks the affected
mass-production SoCs (ESP32-C5/C61/H2/P4). On these SoCs, when hardware Secure
Boot V2 is enabled, the ECDSA (V2) signing scheme is no longer offered by
default; it must be turned on explicitly via SECURE_BOOT_V2_FORCE_ENABLE_ECDSA
under "Allow potentially insecure options" (CONFIG_SECURE_BOOT_INSECURE). App
signing without hardware Secure Boot is not affected. Note that ESP32-C61 has no
RSA based Secure Boot V2, so it has no Secure Boot scheme enabled by default.

The preview targets ESP32-H4 and ESP32-H21 mark ECDSA Secure Boot V2 as not
supported in their SoC capabilities instead of using the option above. As
ESP32-H4 has no other Secure Boot V2 scheme, Secure Boot is disabled entirely on
it; ESP32-H21 retains RSA based Secure Boot V2.

The security documentation keeps the ECDSA Secure Boot V2 content visible and
adds a warning describing the limitation (including that ECDSA Secure Boot V2 on
ESP32-C61 is not recommended for production). CI apps that exercise ECDSA Secure
Boot V2 on the affected SoCs set CONFIG_SECURE_BOOT_V2_FORCE_ENABLE_ECDSA
accordingly.
2026-06-10 03:10:27 +05:30
harshal.patil
72ea236270 fix(esp_tee): Reset crypto peripherals before the panic-induced reset 2026-06-09 18:12:05 +05:30
Alexey Lapshin
8e4c3f5c0d fix(esp_tee): fix buffer overflow 2026-06-05 12:25:23 +07:00
Sudeep Mohanty
56b2414dee fix(esp_tee): Stop esp_tee subproject to be built with build system v2
- Unset IDF_BUILD_V2 in subproject/CMakeLists.txt before including
  project.cmake so the nested esp_tee ExternalProject cmake stays on
  cmakev1.
- Read PARTITION_TABLE_BIN_PATH as a generator expression under
  IDF_BUILD_V2 to defer the lookup to CMake's generate phase.
2026-05-26 13:10:41 +02:00
harshal.patil
4821f331fe refactor(mbedtls/test): Move the mbedtls test app to support multiple test apps 2026-05-15 09:09:15 +05:30
Michael (XIAO Xufeng)
636f56f6ce Merge branch 'fix/s3_xip_opt_os_startup' into 'master'
fix(mspi): fixed possible boot failure in some builds when psram is enabled

Closes IDF-15634 and IDF-15637

See merge request espressif/esp-idf!48258
2026-05-13 18:55:35 +08:00
Xiao Xufeng
a671c83b0b fix(mspi): fixed possible boot failure in some builds when psram is enabled
A typical scenario is: when XIP on PSRAM enabled, compiler optimization level is Os. Under certain binary layout, boot hangs and backtrace points to `esp_sleep_config_gpio_isolate`.

The root cause is that, during PSRAM initialization, it calls esp_gpio_reserve, which happens to place before the reported function. However, after call, there is no barrier before the clock adjustment in `mspi_timing_enter_low_speed_mode`. The clock gets changed when the cache is still fetching data, resulting in the corrupted data in the end of the cache line.

This commits add spi_flash_disable_cache as a barrier to make sure the cache transactions is finished before the clock switch.
2026-05-13 16:46:20 +08:00
Laukik Hase
281d219fac feat(esp_tee): Clear out all sensitive buffers explicitly after TEE crypto operations 2026-05-12 13:56:28 +05:30
Laukik Hase
51ac92e737 ci(esp_tee): Add test-case for verifying the TEE Secure Storage encryption 2026-05-11 16:56:57 +05:30
Laukik Hase
4f3f1dff5a feat(esp_tee): Add some required fields in the attestation token
- Chip ID from the ROM
- Device MAC address from eFuse BLK1
- Device Optional Unique ID from eFuse BLK2
2026-05-11 16:29:19 +05:30
Guillaume Souchere
a56354e9ab feat(heap): move TLSF ROM patches and related files from esp_rom to heap
The TLSF ROM patch code (rom_patch_tlsf.c, rom_patch_multi_heap.c),
their headers, and the per-target *.rom.heap.ld linker scripts are
semantically owned by the heap component, not esp_rom. Move them
accordingly:

- components/esp_rom/patches/esp_rom_tlsf.c
  → components/heap/rom_patches/rom_patch_tlsf.c
- components/esp_rom/patches/esp_rom_multi_heap.c
  → components/heap/rom_patches/rom_patch_multi_heap.c
- components/esp_rom/include/esp_rom_tlsf.h
  → components/heap/rom_patches/include/rom_patch_tlsf.h
- components/esp_rom/include/esp_rom_multi_heap.h
  → components/heap/rom_patches/include/rom_patch_multi_heap.h
- components/esp_rom/<target>/ld/<target>.rom.heap.ld (×8)
  → components/heap/port/<target>/ld/<target>.rom.heap.ld

Update heap/CMakeLists.txt to:
- use target_linker_script() directly for *.rom.heap.ld
- guard post-registration ROM patch setup with NOT BOOTLOADER_BUILD
- drop stale CONFIG_HEAP_TLSF_CHECK_PATCH symbol reference
- drop esp_rom_include_multi_heap_patch from TLSF_CHECK_PATCH guard

Remove the corresponding entries from esp_rom/CMakeLists.txt.
2026-04-23 12:21:31 +02:00
Mahavir Jain
96194f19a6 Merge branch 'fix/esp-tee-validation-clobber-and-deref-before-check' into 'master'
fix(esp_tee): prevent validation clobbering and deref-before-check in secure services

See merge request espressif/esp-idf!47589
2026-04-21 11:17:31 +05:30
Aditya Patwardhan
2de0ed6a2b fix(esp_tee): prevent validation clobbering and deref-before-check
TEE secure-service handlers had two bugs letting REE bypass
pointer-region validation:

1. valid_addr = instead of valid_addr &= in AEAD encrypt/decrypt
   and DS sign handlers, clobbering prior failed checks.
   Impact: REE writes to TEE DRAM via DS signature output, or reads
   TEE DRAM via AEAD output.

2. data->rsa_length dereferenced before data is validated in DS sign
   and DS start_sign handlers.

Fix: use &= for subsequent checks, add early return after initial
data pointer check in DS handlers.
2026-04-14 14:41:59 +05:30
Laukik Hase
764626a1b7 change(esp_tee): Move the internal memory secure service call table to IRAM
- Using PMA, the TEE IRAM is marked as R/X while TEE DRAM is marked as R/W.
  Moving the internal memory secure service call table from DRAM to IRAM
  makes it immutable.
2026-04-13 12:43:26 +05:30