CVE-2026-55283 AI-generated analysis
platform/hardware/nxp/nfc, NXP NCI HAL (pn8x/halimpl and snxxx/halimpl phNxpNciHal.cc), hal_nfc_default process
In the NXP NFC HAL (hardware/nxp/nfc), the teardown paths changed by the fix now zero nxpncihal_ctrl.gDrvCfg.nClientId before phOsalNfc_Timer_Cleanup() and release the message queue using a saved copy of the id, so per the commit message a late POSIX timer callback sees a zero id instead of reaching the freed message queue. A follow-up makes phNxpNciHal_client_thread break out of its loop when msgrcv fails with the id zeroed, instead of spinning.
Root cause
Several HAL teardown paths called phOsalNfc_Timer_Cleanup(), then phTmlNfc_Shutdown()/phTmlNfc_CleanUp(), then phDal4Nfc_msgrelease(nxpncihal_ctrl.gDrvCfg.nClientId) and a memset of nxpncihal_ctrl, and nClientId held the live message-queue id the whole time. These paths are phNxpNciHal_close and phNxpNciHal_Minclose in pn8x, and the close_and_return path and phNxpNciHal_clean_resources in snxxx/halimpl. According to the commit message, a compromised NFC controller could influence POSIX timer delays so that a detached SIGEV_THREAD timer callback outlived its deletion and accessed the freed message queue, a heap use-after-free in hal_nfc_default. Separately, in the hunks shown, three firmware-download and RF-config failure paths called phOsalNfc_Timer_Cleanup()/phTmlNfc_Shutdown* without a phDal4Nfc_msgrelease call. These are pn8x phNxpNciHal_fw_download, pn8x phNxpNciHalRFConfigCmdRecSequence and snxxx phNxpNciHal_force_fw_download.
How the fix works
- Commit 8e5737ab9908 (android-security-16.0.0_r8, 'Fix Use-After-Free in NXP NFC HAL timer teardown') changes pn8x/halimpl/hal/phNxpNciHal.cc phNxpNciHal_close and phNxpNciHal_Minclose, and the close_and_return path and phNxpNciHal_clean_resources in snxxx/halimpl/hal/phNxpNciHal.cc. In each, the live id is copied into a local `intptr_t client_id`, then nxpncihal_ctrl.gDrvCfg.nClientId is set to 0 before phOsalNfc_Timer_Cleanup(). The later phDal4Nfc_msgrelease() call now uses the saved client_id instead of the global. The commit message says timer callbacks that see a zero queue id return early. That callback-side check is not in the diff.
- The same commit gives the same save-and-zero sequence to three failure branches: pn8x phNxpNciHal_fw_download (version mismatch), pn8x phNxpNciHalRFConfigCmdRecSequence (TML read error) and snxxx phNxpNciHal_force_fw_download (integrity failed or version mismatch). Each also gets a new phDal4Nfc_msgrelease(client_id) call after phTmlNfc_Shutdown_CleanUp()/phTmlNfc_Shutdown().
- Commit 2c6606f830e5 (android-security-16.0.0_r10, 'Fix infinite loop and logcat spam in NXP NFC HAL teardown') handles a side effect. Per its commit message, when nClientId is zeroed during teardown, phDal4Nfc_msgrcv() returns -1 immediately. phNxpNciHal_client_thread (pn8x and snxxx/halimpl) then hit `continue`, which skipped the thread_running check and spun at 100% CPU with logcat spam. The fix adds a check in the -1 branch, before the existing 'received bad message' log and continue: `if (p_nxpncihal_ctrl->thread_running == 0 || p_nxpncihal_ctrl->gDrvCfg.nClientId == 0) { log; break; }`. The diff of this commit, as provided, also contains all the changes from the first commit (same base blobs a246e52/018a1ef).
Completeness
- The fix covers the teardown paths changed in the diff. In pn8x/halimpl/hal/phNxpNciHal.cc these are phNxpNciHal_close, phNxpNciHal_Minclose, the phNxpNciHal_fw_download failure branch and the phNxpNciHalRFConfigCmdRecSequence failure branch. In snxxx/halimpl/hal/phNxpNciHal.cc they are close_and_return, phNxpNciHal_clean_resources and the phNxpNciHal_force_fw_download failure branch. The material does not show whether other teardown paths exist.
- The Android 16 commits touch only pn8x/halimpl and snxxx/halimpl, although the UAF commit message also names snxxx/halimpl_v2. Per index search, snxxx/halimpl_v2 files exist in the Android 16 tree (dnld files at android-16.0.0_r4). The Android 17 commit e245c4b5a851 patches snxxx/halimpl_v2/hal/phNxpNciHal.cc, but no halimpl_v2 change is shown for Android 16.
- The fix depends on the timer callback checking for a zero nClientId and returning early (stated in the commit message). That check is not part of the diff.
- The loop fix is applied only to phNxpNciHal_client_thread. The commit message also names ReaderThread, WriterThread and MessageQueue_receive, which do not appear in the diff, so the shown changes do not cover any equivalent loops in those threads.
Behavior changes
- Three failure paths (pn8x phNxpNciHal_fw_download, pn8x phNxpNciHalRFConfigCmdRecSequence, snxxx phNxpNciHal_force_fw_download) now call phDal4Nfc_msgrelease(client_id) and release the message queue.
- nxpncihal_ctrl.gDrvCfg.nClientId reads as 0 from just before phOsalNfc_Timer_Cleanup() in teardown, instead of only after the final memset.
- phNxpNciHal_client_thread now exits with an error log 'NFC client thread terminating' when msgrcv fails and thread_running==0 or nClientId==0. Before, it logged 'received bad message' and retried.
Per major
- Android 14: Not listed by the bulletin (not affected per the bulletin). The resolver reports 8/8 lines of the patched region present at android-security-14.0.0_r31. No fix commit for 14 is shown.
- Android 15: Not listed by the bulletin (not affected per the bulletin). The resolver reports 8/8 lines of the patched region present at android-security-15.0.0_r19. No fix commit for 15 is shown.
- Android 16: Same fix. The UAF commit 8e5737ab9908 landed in android-security-16.0.0_r8 (pn8x/halimpl and snxxx/halimpl only). The loop-exit follow-up 2c6606f830e5 landed in android-security-16.0.0_r10. 8/8 lines present at r10.
- Android 17: Adapted fix. Commit e245c4b5a851 in android-security-17.0.0_r1 has the same pn8x and snxxx/halimpl changes. It also changes snxxx/halimpl_v2/hal/phNxpNciHal.cc (phNxpNciHal_force_fw_download, close_and_return, phNxpNciHal_clean_resources), but there it only inserts `nxpncihal_ctrl.gDrvCfg.nClientId = 0;` before phOsalNfc_Timer_Cleanup(), with no saved client_id and no msgrelease change. 8/8 lines present at android-security-17.0.0_r3. The material does not show whether the loop-exit follow-up landed on 17.
Unknowns
- The timer callback / phDal4Nfc code that should return early on a zero client id is not shown. Its existence is only stated in the commit message.
- Whether a timer callback thread can still be running when the queue is released after the reordering, since there is no join or synchronization in the diff and the callback code is not shown.
- Whether ReaderThread, WriterThread or MessageQueue_receive (named in the loop-fix commit message) got equivalent break logic, and in which file.
- Whether the loop-exit follow-up (Change-Id Ia366fe7d...) was merged on the Android 17 security branch.
- Whether snxxx/halimpl_v2/hal/phNxpNciHal.cc on Android 16 has the same unfixed teardown sequence.
- Why Android 14/15 are listed as not affected while the resolver finds the patched region present in their latest security tags.