Commit Graph

54221 Commits

Author SHA1 Message Date
Konstantin Kondrashov
268a9b071f Merge branch 'fix/esp-event-security-fixes' into 'master'
fix(esp_event): multiple security and stability fixes

Closes SEC-064, SEC-219, SEC-220, SEC-221, SEC-222, and IDFGH-17955

See merge request espressif/esp-idf!50442
2026-07-21 16:27:51 +03:00
Adam Múdry
b1755caa63 Merge branch 'fix/sdmmc_bdl_casting' into 'master'
fix(sdmmc): BDL calculate sectors cast fix

Closes IDFGH-18017

See merge request espressif/esp-idf!51039
2026-07-21 15:15:33 +02:00
Konstantin Kondrashov
82e6c831e7 fix(esp_event): free queued legacy cleanup ctx on loop delete
When a loop is deleted while an internal legacy "cleanup" event is still
queued (posted by a deferred self-unregistration from within a handler),
esp_event_loop_delete() drained the queue but only freed the post payload,
leaking the heap copy of the handler context allocated for the legacy path.

Free ctx->handler_ctx for queued legacy cleanup events while draining the
queue, mirroring the cleanup done in esp_event_loop_run().

Add a regression test that leaves a legacy cleanup event queued and asserts
no memory is leaked on loop deletion.
2026-07-21 15:33:47 +03:00
Konstantin Kondrashov
e8ffb477a0 fix(esp_event): clear running_task before releasing mutex on tick timeout
When esp_event_loop_run() exited via the ticks-expired break path,
loop->running_task was left pointing to the current task handle.
Any subsequent trylock in esp_event_handler_unregister_with_internal()
would see a stale non-NULL running_task and take the wrong code path.
2026-07-21 15:25:58 +03:00
Konstantin Kondrashov
9d2d32524b fix(esp_event): prevent UAF race between post and loop delete (SEC-222)
esp_event_post_to() could access loop->queue / loop->mutex after
esp_event_loop_delete() freed them when both ran concurrently.

Introduce esp_event_loop_state_t with:
- posts_in_flight: reference-count incremented atomically (under
  state.lock spinlock) before touching any loop resources, decremented
  on every exit path via goto on_err.
- deleting: atomic_bool set by esp_event_loop_delete() to block new
  posts from entering the critical section.

esp_event_loop_delete() sets deleting=true, then busy-waits (releasing
and re-acquiring loop->mutex each tick) until posts_in_flight reaches
zero before proceeding with teardown.

esp_event_isr_post_to() performs a lock-free atomic_load of deleting as
a best-effort guard; ISR context cannot participate in the spinlock
protocol but the window is documented and accepted.
2026-07-21 15:25:58 +03:00
Konstantin Kondrashov
736275e562 fix(esp_event): skip dispatch for internal cleanup events (SEC-221)
After processing an esp_event_handler_cleanup sentinel, execution fell
through into the regular dispatch block. Every loop-level (ANY_BASE/
ANY_ID) handler was invoked with base="cleanup" and event_data pointing
at the internal esp_event_remove_handler_context_t struct.

Consequences:
- Information disclosure: internal handler addresses and loop instance
  pointer are exposed to every loop-level handler.
- UAF: if a handler stores event_data for later use, post_instance_delete
  frees the ctx, turning the stored pointer into a dangling reference.
- Logic corruption: handlers that switch on base with a default branch
  misbehave on every unregister anywhere in the system.

Fix: wrap the regular dispatch block in an else clause so it is skipped
entirely for cleanup events. post_instance_delete, ticks accounting, and
xSemaphoreGiveRecursive remain in the shared tail executed for both paths.

Closes SEC_221
2026-07-21 15:25:57 +03:00
Konstantin Kondrashov
4ab4d5b894 fix(esp_event): use recursive mutex API in handler unregister (SEC-220)
1) loop->mutex is created with xSemaphoreCreateRecursiveMutex(). FreeRTOS
requires that recursive mutexes are only acquired and released with
xSemaphoreTakeRecursive / xSemaphoreGiveRecursive.

esp_event_handler_unregister_with_internal() used the non-recursive
xSemaphoreTake(loop->mutex, 0) / xSemaphoreGive(loop->mutex) in the fast
path. The non-recursive Take bypasses uxRecursiveCallCount bookkeeping;
if the same task subsequently takes the mutex recursively (e.g. re-entry
from a handler or a follow-up register), the call count drifts. The
non-recursive Give then unconditionally drops the holder, allowing another
task to acquire the mutex while the original task still believes it holds
the lock — a full lock violation on the handler list leading to UAF and
potential RCE on attacker-driven event floods.

Fix: replace xSemaphoreTake/xSemaphoreGive with the Recursive variants in
the fast (try-take with timeout 0) path of unregister_with_internal.

2) avoid use-after-free when unregistering handler from a callback

The recursive try-lock introduced in SEC-220 succeeds re-entrantly when a
handler unregisters itself from within its own callback, causing the handler
node to be freed immediately while the dispatch loop still writes profiling
counters to it after the callback returns. Route the in-callback case to the
deferred cleanup path and only free directly once no dispatch is active.

Closes SEC_220
2026-07-21 15:25:57 +03:00
Konstantin Kondrashov
2c935ea861 fix(esp_event): protect is_handler_registered traversal with mutex (SEC-219)
esp_event_is_handler_registered() walked loop_nodes, base_nodes, id_nodes
and handler lists with no lock held, then released an unowned mutex at the
'out:' label via xSemaphoreGive().

Concurrent register/unregister/delete operations can free handler nodes
during the unlocked walk (SLIST UAF). The xSemaphoreGive on an unowned
recursive mutex corrupts the recursive call-count of any task that
legitimately holds the mutex.

Fix:
- Take loop->mutex with xSemaphoreTakeRecursive before the traversal.
- Replace xSemaphoreGive at the 'out:' label with xSemaphoreGiveRecursive
  so every exit path holds the mutex for exactly one balanced take/give.

Closes SEC_219
2026-07-21 15:25:57 +03:00
Adam Múdry
7961a7a65f fix(sdmmc): BDL calculate sectors cast fix
Closes https://github.com/espressif/esp-idf/issues/18875
2026-07-21 14:06:56 +02:00
Chen Ji Chang
0bae8d1e27 Merge branch 'change/remove_lcd_restart_for_p4_s31' into 'master'
remove(lcd): remove restart support for p4 and s31

Closes IDF-15849 and IDF-15960

See merge request espressif/esp-idf!50892
2026-07-21 15:41:27 +08:00
Chen Jichang
294f35cb03 test(dma): add psram ecc test for supported targets 2026-07-21 14:50:23 +08:00
morris
e8a5192a18 Merge branch 'ci/fix_the_parlio_rx_spi_test_case' into 'master'
ci(parlio_rx): fixed the parlio rx spi test case

Closes IDF-9806

See merge request espressif/esp-idf!43536
2026-07-21 10:54:05 +08:00
Jiang Jiang Jian
e41650a966 Merge branch 'bugfix/remove_phy_lib_librfate' into 'master'
fix(phy): removed all librfate logic from cmake

Closes IDFCI-13345

See merge request espressif/esp-idf!50940
2026-07-21 10:49:48 +08:00
Island
de98d9d4ad Merge branch 'feat/feat_support_phy_enable_using_regdma' into 'master'
Feat/feat support phy enable using regdma

Closes BLERP-2376, BLERP-2381, and PM-635

See merge request espressif/esp-idf!46356
2026-07-21 10:40:03 +08:00
Island
c3083dfae5 Merge branch 'opt/bluedroid_trace_none_without_ble_log_host' into 'master'
change(ble/bluedroid): disable host trace logs when BLE Log host is off

See merge request espressif/esp-idf!50902
2026-07-21 10:39:36 +08:00
Island
30c632bebb Merge branch 'bugfix/fix_bluedroid_set_rand_addr_during_scan' into 'master'
fix(ble/bluedroid): report set rand addr result on HCI complete

Closes BLERP-2965

See merge request espressif/esp-idf!50663
2026-07-21 10:39:27 +08:00
Island
bf05267d95 Merge branch 'fix/ble_hidd_remove_ccc_gating' into 'master'
fix(esp_hid/bluedroid): remove app-layer CCC gating in HID device

Closes BCI-601

See merge request espressif/esp-idf!50766
2026-07-21 10:39:23 +08:00
morris
6889f38644 Merge branch 'feat/enable_debug_record_s31' into 'master'
feat(hal): implement enable_debug/enable_record for ESP32S31 CPU utility

Closes IDF-14675

See merge request espressif/esp-idf!50983
2026-07-20 21:29:44 +08:00
Fu Hanxi
b260448d30 Merge branch 'ci/common-scripts' into 'master'
Ci/common scripts

Closes RDT-933

See merge request espressif/esp-idf!50564
2026-07-20 14:18:36 +02:00
Chen Jichang
cf57711b09 ci(parlio_rx): fixed the parlio rx spi test case 2026-07-20 19:31:42 +08:00
Erhan Kurubas
2411f0f52d feat(hal): implement enable_debug/enable_record for ESP32-S31 CPU utility 2026-07-20 12:13:21 +02:00
Island
756b89c852 Merge branch 'change/ble_update_lib_20260717' into 'master'
change(ble): [AUTO_MR] 20260717 - Update ESP BLE Controller Lib

Closes BLERP-2973, BLERP-2974, BLERP-2975, and BLERP-2976

See merge request espressif/esp-idf!50861
2026-07-20 16:42:19 +08:00
Island
e309933c07 Merge branch 'feat/optimize_for_esp32h4_light_sleep_ble_current' into 'master'
Feat/optimize for esp32h4 light sleep ble current

Closes BLERP-2958, BLERP-2959, BLERP-2960, and BLERP-2961

See merge request espressif/esp-idf!50415
2026-07-20 16:42:13 +08:00
zhanghaipeng
1f8f935e3f change(ble/bluedroid): disable host trace logs when BLE Log host is off
Default all Bluedroid layer trace levels to NONE when BLE async log
is enabled without BLE_LOG_HOST_LOG.
2026-07-20 15:43:27 +08:00
Erhan Kurubas
44bc2ac703 Merge branch 'esp_riscv_trace' into 'master'
RISC-V Trace Encoder

See merge request espressif/esp-idf!49821
2026-07-20 09:15:17 +02:00
morris
2da1deee3b Merge branch 'contrib/github_pr_18864' into 'master'
docs: fix duplicate word typos across docs and hal (GitHub PR)

Closes IDFGH-18006

See merge request espressif/esp-idf!50942
2026-07-20 15:02:23 +08:00
muhaidong
d4f6638b07 fix(phy): removed all librfate logic from cmake 2026-07-20 14:24:52 +08:00
Marius Vikhammer
71c8c6df3a Merge branch 'fix/ringbuf_max_item_size' into 'master'
fix(esp_ringbuf): harden ringbuf creation sizes checks

Closes SEC-1118

See merge request espressif/esp-idf!50445
2026-07-20 13:33:18 +08:00
Chen Jichang
9a196c8416 remove(lcd): remove restart support for p4 and s31 2026-07-20 13:19:09 +08:00
Mahavir Jain
ef2d5c887d Merge branch 'feat/mbedtls_update_4.1.1' into 'master'
Feat/mbedtls update 4.1.1

See merge request espressif/esp-idf!50602
2026-07-20 09:34:19 +05:30
Wang Meng Yang
0a43435b7b Merge branch 'fix/ble_log_compression_add_local_header_file' into 'master'
feat(ble_log): mirror local compression headers

See merge request espressif/esp-idf!50870
2026-07-20 11:47:44 +08:00
cjin
8f845298c1 feat(ble): supported placing bt function in iram on esp32-h4 and esp32-s31 2026-07-20 10:48:26 +08:00
cjin
5db0097a27 feat(modem_clock): rename ble mac module to bt mac 2026-07-20 10:48:26 +08:00
cjin
7275f6ffbf feat(modem_clock): separete btmac module to btmac and bt peripheral 2026-07-20 10:48:26 +08:00
cjin
48c53023c8 feat(modem_clock): separate bt sec apb clock and add to bt apb module 2026-07-20 10:48:26 +08:00
cjin
9c432f41b5 feat(modem_clock): added bt_apb module and separete bt_apb from bt_mac module 2026-07-20 10:48:26 +08:00
Ma Jing Jing
fef97f4436 Merge branch 'feature/add_asrc_sleep_retention' into 'master'
feat(asrc): Add sleep retention

See merge request espressif/esp-idf!50719
2026-07-20 02:00:19 +00:00
Atharva-2708
f8544b40df docs: fix duplicate word typos across docs and hal
Removes duplicated "the" typos in FreeRTOS, eFuse, Kconfig documentation, and the HAL README.

Signed-off-by: Atharva-2708 <atharva.btech27@gmail.com>
2026-07-19 15:31:16 +05:30
Kapil Gupta
578e51b26b Merge branch 'bugfix/rmac_scan' into 'master'
fix(esp_wifi): fix issues for scan, and NULL packets tx for random mac

Closes WIFIBUG-2009, WIFIBUG-2008, and WIFIBUG-2029

See merge request espressif/esp-idf!50298
2026-07-18 20:22:49 +05:30
Shreyas Sheth
37646ec2d5 fix(esp_wifi): fix issues for scan, and NULL packets tx for random mac (9bbd59c) 2026-07-18 17:38:50 +08:00
Rahul Tank
4e3756889e Merge branch 'bugfix/add_dis_ieee_udi_to_config' into 'master'
fix(nimble): Add option to disable IEEE and UDI Characteristic in DIS

See merge request espressif/esp-idf!50254
2026-07-18 09:31:15 +05:30
Jiang Jiang Jian
3b11b2d810 Merge branch 'bugfix/nan_mem_corruption' into 'master'
Fix(NAN): fix Memory Corruption due to BIP encryption

Closes WIFIBUG-2035, WIFIBUG-1946, and WIFIBUG-1947

See merge request espressif/esp-idf!50469
2026-07-17 20:39:48 +08:00
Wang Meng Yang
c1eb1922bb Merge branch 'bugfix/hid_host_oob_read' into 'master'
fix(bt/bluedroid): fixed possible 1-byte OOB read in bta_hh_ctrl_dat_act

Closes SEC-786

See merge request espressif/esp-idf!50703
2026-07-17 20:06:45 +08:00
Wang Mengyang
bbd20cae01 fix(bt): Fixed build error on array-bounds in HFP AG 2026-07-17 19:36:51 +08:00
Shu Chen
73b55e893f Merge branch 'support/ot_register_154_event_cb' into 'master'
feat(openthread): use ieee802154 event callback list instead of weak overrides

See merge request espressif/esp-idf!50825
2026-07-17 11:08:50 +00:00
Sonika Rathi
69550b17c8 Merge branch 'bugfix/parttool-serial-handoff' into 'master'
fix(storage): stabilize parttool pytest serial handoff

Closes IDFCI-3899

See merge request espressif/esp-idf!50444
2026-07-17 19:04:06 +08:00
Martin Vychodil
ce31bdda6d Merge branch 'contrib/github_pr_18829' into 'master'
fix(spiffs): fix off-by-one in spiffsgen.py obj name length check (GitHub PR)

Closes IDFGH-17964

See merge request espressif/esp-idf!50671
2026-07-17 18:51:37 +08:00
Erhan Kurubas
2c11810ad9 feat(esp_riscv_trace): add riscv trace encoder driver with hal/ll layer 2026-07-17 12:42:13 +02:00
Sonika Rathi
62317f4dee Merge branch 'bugfix/idfci-12737-fatfs-bdl-wl-storage-erase' into 'master'
fix(fatfs): erase storage partition before bdl_wl CI test

Closes IDFCI-12737

See merge request espressif/esp-idf!50459
2026-07-17 18:36:06 +08:00
Sonika Rathi
6f95ab46f1 Merge branch 'contrib/github_pr_18822' into 'master'
fix(esp_partition): prevent size_t overflow bypassing bounds checks on linux target (GitHub PR)

Closes IDFGH-17957

See merge request espressif/esp-idf!50894
2026-07-17 18:35:24 +08:00