[PATCH net v3 0/3] nfc: fix LLCP, nfcsim, and digital teardown ordering races
From: Bin Luo via B4 Relay
Date: Sun Dec 06 2026 - 05:53:23 EST
This 3-patch series fixes teardown ordering use-after-free and
work/timer re-arming bugs across NFC LLCP, nfcsim, and the NFC Digital
core:
1. Patch 1 reorders local_cleanup() in net/nfc/llcp_core.c using
disable_work_sync() and timer_shutdown_sync() in producer-to-consumer
order and purges tx_queue after tx_work is disabled.
2. Patch 2 stops link_in and permanently disables send_work/recv_work in
nfcsim_device_free() before nfc_digital_unregister_device() drains
ddev->cmd_queue, keeps dev->up = false after unregister so in-flight
commands are not silently dropped without cmd_cb(), and wakes
nfcsim_link_recv_skb() on link->shutdown to prevent teardown stalls.
3. Patch 3 reorders nfc_digital_unregister_device() to stop works and
drain cmd_queue (freeing orphaned cmd->req/cmd->resp skbs) before
nfc_remove_device() tears down LLCP.
Changes in v3:
- Address all Sashiko AI review comments: keep dev->up = false after
nfc_digital_unregister_device() and wake nfcsim_link_recv_skb() on
link->shutdown (Patch 2 Medium x2), free orphaned cmd->req and
cmd->resp skbs in the digital drain loop (Patch 3 Medium), fix Fixes
tags and commit descriptions (Low), and normalize From:/Signed-off-by:
author metadata (Low).
Bin Luo (3):
nfc: llcp: fix work and timer teardown order in local_cleanup()
nfc: nfcsim: stop link and works before unregistering digital device
nfc: digital: stop works and drain commands before nfc_remove_device()
drivers/nfc/nfcsim.c | 23 ++++++++++++-----------
net/nfc/digital_core.c | 15 +++++++++++----
net/nfc/llcp_core.c | 12 ++++++------
3 files changed, 29 insertions(+), 21 deletions(-)
--
2.43.0