[PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock
From: Bin Luo via B4 Relay
Date: Sun Dec 06 2026 - 05:52:35 EST
This 2-patch series fixes socket teardown races and a 30-second
ndev->rx_wq self-deadlock in net/nfc/rawsock.c:
1. Patch 1 serializes SEND_SHUTDOWN updates/checks, write-queue purging,
and tx_work scheduling under sk->sk_write_queue.lock, and ensures
sk->sk_err is written before purging so woken writers observe the NFC
error rather than -EPIPE.
2. Patch 2 removes synchronous nfc_deactivate_target() from
rawsock_destruct() (which deadlocks when called from ndev->rx_wq) and
tracks tx_in_flight under sk_write_queue.lock so close() deactivates
synchronously when idle or defers deactivation to a dedicated unbound
rawsock_wq work item once the in-flight data exchange completes,
preventing any race with driver completion handlers (e.g. pn533
resp_q).
Changes in v3:
- Address all Sashiko AI review comments: defer deactivation until after
in-flight driver completion finishes (Critical), set sk->sk_err via
WRITE_ONCE() prior to write-queue purge (Medium), fix race 2 commit
description and Fixes tag to 23b7869c0fd0 (Low), and normalize
From:/Signed-off-by: author metadata (Low).
Bin Luo (2):
nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown
nfc: rawsock: avoid synchronous target deactivation in
rawsock_destruct()
net/nfc/nfc.h | 3 ++
net/nfc/rawsock.c | 115 ++++++++++++++++++++++++++++++++++++----------
2 files changed, 95 insertions(+), 23 deletions(-)
--
2.43.0