mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v3 2/2] nfc: rawsock: avoid synchronous target deactivation in rawsock_destruct()
  2026-12-06 10:52 [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock Bin Luo via B4 Relay
  2026-12-06 10:52 ` [PATCH net v3 1/2] nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown Bin Luo via B4 Relay
@ 2026-12-06 10:52 ` Bin Luo via B4 Relay
  2026-12-06 10:57 ` [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock netdev-bot+sinfo
  2 siblings, 0 replies; 5+ messages in thread
From: Bin Luo via B4 Relay @ 2026-12-06 10:52 UTC (permalink / raw)
  To: David Heidelberg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman
  Cc: oe-linux-nfc, netdev, linux-kernel, stable

From: Bin Luo <luob87709@gmail.com>

rawsock_destruct() currently calls nfc_deactivate_target(), which
acquires device_lock(&dev->dev) and, for NCI devices, invokes
nci_request(ndev, nci_rf_deactivate_req, ..., NCI_RF_DEACTIVATE_TIMEOUT)
to synchronously wait up to 30 seconds for an RF_DEACTIVATE_RSP/NTF
exchange processed on ndev->rx_wq.

When rawsock_release() drops its reference while an nfc_data_exchange()
is still in flight, rawsock_data_exchange_complete() drops the final
socket reference directly from ndev->rx_wq (inside nci_rx_work()).
That invokes rawsock_destruct() -> nfc_deactivate_target() ->
nci_request() on ndev->rx_wq itself, causing ndev->rx_wq to block for
the full 30-second NCI_RF_DEACTIVATE_TIMEOUT waiting on a response that
only ndev->rx_wq can process:

  nci: __nci_request: wait_for_completion_interruptible_timeout failed 0

Deactivating immediately in rawsock_release() without waiting for an
in-flight nfc_data_exchange() would race with driver completion paths
such as pn533_data_exchange_complete() operating on dev->resp_q.

Track whether a data exchange is currently in flight under
sk->sk_write_queue.lock:

- In rawsock_release(), after cancelling tx_work, deactivate the target
  synchronously if no data exchange is in flight; otherwise mark
  deact_pending so deactivation waits for the in-flight completion.
- In rawsock_data_exchange_complete() (on both success and error
  paths), clear tx_in_flight; if deact_pending is set, transfer the
  in-flight socket reference to a dedicated unbound rawsock_wq work
  item (rawsock_deact_work) that calls nfc_deactivate_target() outside
  ndev->rx_wq and then drops the socket reference.
- Keep nfc_put_device() in rawsock_destruct() so the nfc_dev reference
  remains valid until deactivation finishes, and destroy rawsock_wq in
  rawsock_exit() before unregistering the protocol.

Tested in QEMU KVM (KASAN, LOCKDEP, DEBUG_OBJECTS) with:
- tools/testing/selftests/nci/nci_dev (8/8 passed)
- deferred deactivation invariant tests (10/10 in-flight close deferred
  until after completion, 20/20 idle close synchronous, 5/5 error path)
- 300 single-frame + 300 multi-frame virtual_ncidev teardown race loops
  (600/600 deactivations, 0 timeouts, 0 KASAN/LOCKDEP/WARNING reports)

Fixes: 23b7869c0fd0 ("NFC: add the NFC socket raw protocol")
Cc: stable@vger.kernel.org
Signed-off-by: Bin Luo <luob87709@gmail.com>
---
Changes in v3:
- Fix race with in-flight driver completions (such as pn533 resp_q
  handling) by tracking tx_in_flight under sk_write_queue.lock and
  deferring nfc_deactivate_target() to a dedicated unbound rawsock_wq
  work item when close() occurs while an exchange is still in flight.
- Normalize From:/Signed-off-by: author metadata.

Changes in v2:
- Resend cleanly via b4 web relay and include both dependent rawsock
  patches as a threaded series.

 net/nfc/nfc.h     |  3 ++
 net/nfc/rawsock.c | 73 ++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 66 insertions(+), 10 deletions(-)

diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index 82c5dfd..2819ccd 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -29,7 +29,10 @@ struct nfc_rawsock {
 	struct nfc_dev *dev;
 	u32 target_idx;
 	struct work_struct tx_work;
+	struct work_struct deact_work;
 	bool tx_work_scheduled;
+	bool tx_in_flight;
+	bool deact_pending;
 };

 struct nfc_sock_list {
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index 2fa0f05..b8aa2de 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -20,6 +20,18 @@ static struct nfc_sock_list raw_sk_list = {
 	.lock = __RW_LOCK_UNLOCKED(raw_sk_list.lock)
 };

+static struct workqueue_struct *rawsock_wq;
+
+static void rawsock_deact_work(struct work_struct *work)
+{
+	struct nfc_rawsock *rsk = container_of(work, struct nfc_rawsock,
+					       deact_work);
+	struct sock *sk = &rsk->sk;
+
+	nfc_deactivate_target(rsk->dev, rsk->target_idx, NFC_TARGET_MODE_IDLE);
+	sock_put(sk);
+}
+
 static void nfc_sock_link(struct nfc_sock_list *l, struct sock *sk)
 {
 	write_lock(&l->lock);
@@ -68,6 +80,8 @@ static int rawsock_release(struct socket *sock)
 		nfc_sock_unlink(&raw_sk_list, sk);

 	if (sk->sk_state = TCP_ESTABLISHED) {
+		bool do_deact = false;
+
 		/* Prevent rawsock_tx_work from starting new transmits and
 		 * wait for any in-progress work to finish.  This must happen
 		 * before the socket is orphaned to avoid a race where
@@ -78,6 +92,18 @@ static int rawsock_release(struct socket *sock)
 		__rawsock_write_queue_purge(sk);
 		spin_unlock_bh(&sk->sk_write_queue.lock);
 		cancel_work_sync(&nfc_rawsock(sk)->tx_work);
+
+		spin_lock_bh(&sk->sk_write_queue.lock);
+		if (nfc_rawsock(sk)->tx_in_flight)
+			nfc_rawsock(sk)->deact_pending = true;
+		else
+			do_deact = true;
+		spin_unlock_bh(&sk->sk_write_queue.lock);
+
+		if (do_deact)
+			nfc_deactivate_target(nfc_rawsock(sk)->dev,
+					      nfc_rawsock(sk)->target_idx,
+					      NFC_TARGET_MODE_IDLE);
 	}

 	sock_orphan(sk);
@@ -153,6 +179,7 @@ static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb,
 					   int err)
 {
 	struct sock *sk = (struct sock *) context;
+	bool defer_deact = false;

 	BUG_ON(in_hardirq());

@@ -170,14 +197,22 @@ static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb,
 		goto error_skb;

 	spin_lock_bh(&sk->sk_write_queue.lock);
-	if (!(sk->sk_shutdown & SEND_SHUTDOWN) &&
-	    !skb_queue_empty(&sk->sk_write_queue))
+	nfc_rawsock(sk)->tx_in_flight = false;
+	if (nfc_rawsock(sk)->deact_pending) {
+		nfc_rawsock(sk)->tx_work_scheduled = false;
+		defer_deact = true;
+	} else if (!(sk->sk_shutdown & SEND_SHUTDOWN) &&
+		   !skb_queue_empty(&sk->sk_write_queue)) {
 		schedule_work(&nfc_rawsock(sk)->tx_work);
-	else
+	} else {
 		nfc_rawsock(sk)->tx_work_scheduled = false;
+	}
 	spin_unlock_bh(&sk->sk_write_queue.lock);

-	sock_put(sk);
+	if (defer_deact)
+		queue_work(rawsock_wq, &nfc_rawsock(sk)->deact_work);
+	else
+		sock_put(sk);
 	return;

 error_skb:
@@ -185,7 +220,15 @@ error_skb:

 error:
 	rawsock_report_error(sk, err);
-	sock_put(sk);
+	spin_lock_bh(&sk->sk_write_queue.lock);
+	nfc_rawsock(sk)->tx_in_flight = false;
+	defer_deact = nfc_rawsock(sk)->deact_pending;
+	spin_unlock_bh(&sk->sk_write_queue.lock);
+
+	if (defer_deact)
+		queue_work(rawsock_wq, &nfc_rawsock(sk)->deact_work);
+	else
+		sock_put(sk);
 }

 static void rawsock_tx_work(struct work_struct *work)
@@ -211,6 +254,7 @@ static void rawsock_tx_work(struct work_struct *work)
 		spin_unlock_bh(&sk->sk_write_queue.lock);
 		return;
 	}
+	nfc_rawsock(sk)->tx_in_flight = true;
 	spin_unlock_bh(&sk->sk_write_queue.lock);
 	kcov_remote_start_common(skb_get_kcov_handle(skb));

@@ -219,6 +263,9 @@ static void rawsock_tx_work(struct work_struct *work)
 			       rawsock_data_exchange_complete, sk);
 	if (rc) {
 		rawsock_report_error(sk, rc);
+		spin_lock_bh(&sk->sk_write_queue.lock);
+		nfc_rawsock(sk)->tx_in_flight = false;
+		spin_unlock_bh(&sk->sk_write_queue.lock);
 		sock_put(sk);
 	}
 	kcov_remote_stop();
@@ -332,12 +379,8 @@ static void rawsock_destruct(struct sock *sk)
 {
 	pr_debug("sk=%p\n", sk);

-	if (sk->sk_state = TCP_ESTABLISHED) {
-		nfc_deactivate_target(nfc_rawsock(sk)->dev,
-				      nfc_rawsock(sk)->target_idx,
-				      NFC_TARGET_MODE_IDLE);
+	if (sk->sk_state = TCP_ESTABLISHED)
 		nfc_put_device(nfc_rawsock(sk)->dev);
-	}

 	skb_queue_purge(&sk->sk_receive_queue);

@@ -377,7 +420,10 @@ static int rawsock_create(struct net *net, struct socket *sock,
 		nfc_sock_link(&raw_sk_list, sk);
 	else {
 		INIT_WORK(&nfc_rawsock(sk)->tx_work, rawsock_tx_work);
+		INIT_WORK(&nfc_rawsock(sk)->deact_work, rawsock_deact_work);
 		nfc_rawsock(sk)->tx_work_scheduled = false;
+		nfc_rawsock(sk)->tx_in_flight = false;
+		nfc_rawsock(sk)->deact_pending = false;
 	}

 	return 0;
@@ -437,12 +483,19 @@ int __init rawsock_init(void)
 {
 	int rc;

+	rawsock_wq = alloc_workqueue("nfc_rawsock", WQ_UNBOUND, 0);
+	if (!rawsock_wq)
+		return -ENOMEM;
+
 	rc = nfc_proto_register(&rawsock_nfc_proto);
+	if (rc)
+		destroy_workqueue(rawsock_wq);

 	return rc;
 }

 void rawsock_exit(void)
 {
+	destroy_workqueue(rawsock_wq);
 	nfc_proto_unregister(&rawsock_nfc_proto);
 }
--
2.43.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock
@ 2026-12-06 10:52 Bin Luo via B4 Relay
  2026-12-06 10:52 ` [PATCH net v3 1/2] nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown Bin Luo via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bin Luo via B4 Relay @ 2026-12-06 10:52 UTC (permalink / raw)
  To: David Heidelberg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman
  Cc: oe-linux-nfc, netdev, linux-kernel, stable

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




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v3 1/2] nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown
  2026-12-06 10:52 [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock Bin Luo via B4 Relay
@ 2026-12-06 10:52 ` Bin Luo via B4 Relay
  2026-12-06 10:52 ` [PATCH net v3 2/2] nfc: rawsock: avoid synchronous target deactivation in rawsock_destruct() Bin Luo via B4 Relay
  2026-12-06 10:57 ` [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock netdev-bot+sinfo
  2 siblings, 0 replies; 5+ messages in thread
From: Bin Luo via B4 Relay @ 2026-12-06 10:52 UTC (permalink / raw)
  To: David Heidelberg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman
  Cc: oe-linux-nfc, netdev, linux-kernel, stable

From: Bin Luo <luob87709@gmail.com>

Commit d793458c45df ("nfc: rawsock: cancel tx_work before socket
teardown") set SEND_SHUTDOWN and called cancel_work_sync(&tx_work)
before rawsock_write_queue_purge() in rawsock_release().

However, two races remain on tx_work and sk_write_queue:

1. rawsock_release() sets SEND_SHUTDOWN without holding
   sk_write_queue.lock and purges sk_write_queue only after
   cancel_work_sync().  Meanwhile, rawsock_data_exchange_complete()
   checks !skb_queue_empty(&sk->sk_write_queue) without checking
   SEND_SHUTDOWN and schedules tx_work without holding a socket
   reference.  If an in-flight completion runs between
   cancel_work_sync() and rawsock_write_queue_purge(), it reschedules
   tx_work while rawsock_release() proceeds to drop the final socket
   reference, leaving tx_work queued on a freed sock.

2. rawsock_tx_work() checks SEND_SHUTDOWN without sk_write_queue.lock
   and then passes skb = skb_dequeue(&sk->sk_write_queue) directly to
   skb_get_kcov_handle(skb) and nfc_data_exchange() without checking
   for NULL.  If rawsock_report_error() purges sk_write_queue in
   between, skb is NULL and dereferencing it crashes.

Serialize SEND_SHUTDOWN updates/checks, write-queue purging, and
tx_work scheduling under sk->sk_write_queue.lock:

- In rawsock_release(), set SEND_SHUTDOWN and purge sk_write_queue
  under sk_write_queue.lock before calling cancel_work_sync().
- In rawsock_data_exchange_complete() and rawsock_sendmsg(), refuse to
  enqueue or schedule tx_work once SEND_SHUTDOWN is set.
- In rawsock_tx_work(), check SEND_SHUTDOWN and dequeue skb under
  sk_write_queue.lock, returning cleanly if the queue is empty.
- In rawsock_report_error(), record sk->sk_err with WRITE_ONCE() before
  acquiring sk_write_queue.lock so any waiters woken by sock_wfree()
  during queue purging observe the NFC error rather than -EPIPE, then
  call sk_error_report() after unlocking.

Fixes: d793458c45df ("nfc: rawsock: cancel tx_work before socket teardown")
Fixes: 23b7869c0fd0 ("NFC: add the NFC socket raw protocol")
Cc: stable@vger.kernel.org
Signed-off-by: Bin Luo <luob87709@gmail.com>
---
Changes in v3:
- In rawsock_report_error(), write sk->sk_err with WRITE_ONCE() before
  acquiring sk_write_queue.lock so waiters woken by sock_wfree() during
  write-queue purging see the NFC error instead of -EPIPE.
- Drop the inaccurate rawsock_release() mention from the race 2
  description and fix the second Fixes tag to 23b7869c0fd0.
- Normalize From:/Signed-off-by: author metadata.

Changes in v2:
- Resend cleanly via b4 web relay and include both dependent rawsock
  patches as a threaded series.

 net/nfc/rawsock.c | 46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index f7d7a59..2fa0f05 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -34,25 +34,25 @@ static void nfc_sock_unlink(struct nfc_sock_list *l, struct sock *sk)
 	write_unlock(&l->lock);
 }

-static void rawsock_write_queue_purge(struct sock *sk)
+static void __rawsock_write_queue_purge(struct sock *sk)
 {
 	pr_debug("sk=%p\n", sk);

-	spin_lock_bh(&sk->sk_write_queue.lock);
 	__skb_queue_purge(&sk->sk_write_queue);
 	nfc_rawsock(sk)->tx_work_scheduled = false;
-	spin_unlock_bh(&sk->sk_write_queue.lock);
 }

 static void rawsock_report_error(struct sock *sk, int err)
 {
 	pr_debug("sk=%p err=%d\n", sk, err);

+	WRITE_ONCE(sk->sk_err, -err);
+	spin_lock_bh(&sk->sk_write_queue.lock);
 	sk->sk_shutdown = SHUTDOWN_MASK;
-	sk->sk_err = -err;
-	sk_error_report(sk);
+	__rawsock_write_queue_purge(sk);
+	spin_unlock_bh(&sk->sk_write_queue.lock);

-	rawsock_write_queue_purge(sk);
+	sk_error_report(sk);
 }

 static int rawsock_release(struct socket *sock)
@@ -73,9 +73,11 @@ static int rawsock_release(struct socket *sock)
 		 * before the socket is orphaned to avoid a race where
 		 * rawsock_tx_work runs after the NCI device has been freed.
 		 */
+		spin_lock_bh(&sk->sk_write_queue.lock);
 		sk->sk_shutdown |= SEND_SHUTDOWN;
+		__rawsock_write_queue_purge(sk);
+		spin_unlock_bh(&sk->sk_write_queue.lock);
 		cancel_work_sync(&nfc_rawsock(sk)->tx_work);
-		rawsock_write_queue_purge(sk);
 	}

 	sock_orphan(sk);
@@ -168,7 +170,8 @@ static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb,
 		goto error_skb;

 	spin_lock_bh(&sk->sk_write_queue.lock);
-	if (!skb_queue_empty(&sk->sk_write_queue))
+	if (!(sk->sk_shutdown & SEND_SHUTDOWN) &&
+	    !skb_queue_empty(&sk->sk_write_queue))
 		schedule_work(&nfc_rawsock(sk)->tx_work);
 	else
 		nfc_rawsock(sk)->tx_work_scheduled = false;
@@ -195,12 +198,20 @@ static void rawsock_tx_work(struct work_struct *work)

 	pr_debug("sk=%p target_idx=%u\n", sk, target_idx);

+	spin_lock_bh(&sk->sk_write_queue.lock);
 	if (sk->sk_shutdown & SEND_SHUTDOWN) {
-		rawsock_write_queue_purge(sk);
+		__rawsock_write_queue_purge(sk);
+		spin_unlock_bh(&sk->sk_write_queue.lock);
 		return;
 	}

-	skb = skb_dequeue(&sk->sk_write_queue);
+	skb = __skb_dequeue(&sk->sk_write_queue);
+	if (!skb) {
+		nfc_rawsock(sk)->tx_work_scheduled = false;
+		spin_unlock_bh(&sk->sk_write_queue.lock);
+		return;
+	}
+	spin_unlock_bh(&sk->sk_write_queue.lock);
 	kcov_remote_start_common(skb_get_kcov_handle(skb));

 	sock_hold(sk);
@@ -239,14 +250,19 @@ static int rawsock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 	}

 	spin_lock_bh(&sk->sk_write_queue.lock);
-	__skb_queue_tail(&sk->sk_write_queue, skb);
-	if (!nfc_rawsock(sk)->tx_work_scheduled) {
-		schedule_work(&nfc_rawsock(sk)->tx_work);
-		nfc_rawsock(sk)->tx_work_scheduled = true;
+	if (sk->sk_shutdown & SEND_SHUTDOWN) {
+		rc = -EPIPE;
+		kfree_skb(skb);
+	} else {
+		__skb_queue_tail(&sk->sk_write_queue, skb);
+		if (!nfc_rawsock(sk)->tx_work_scheduled) {
+			schedule_work(&nfc_rawsock(sk)->tx_work);
+			nfc_rawsock(sk)->tx_work_scheduled = true;
+		}
 	}
 	spin_unlock_bh(&sk->sk_write_queue.lock);

-	return len;
+	return rc ? : len;
 }

 static int rawsock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
--
2.43.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock
  2026-12-06 10:52 [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock Bin Luo via B4 Relay
  2026-12-06 10:52 ` [PATCH net v3 1/2] nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown Bin Luo via B4 Relay
  2026-12-06 10:52 ` [PATCH net v3 2/2] nfc: rawsock: avoid synchronous target deactivation in rawsock_destruct() Bin Luo via B4 Relay
@ 2026-12-06 10:57 ` netdev-bot+sinfo
  2026-12-06 11:04   ` bin luo
  2 siblings, 1 reply; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-12-06 10:57 UTC (permalink / raw)
  To: Bin Luo
  Cc: David Heidelberg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, oe-linux-nfc, netdev, linux-kernel,
	stable

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock
  2026-12-06 10:57 ` [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock netdev-bot+sinfo
@ 2026-12-06 11:04   ` bin luo
  0 siblings, 0 replies; 5+ messages in thread
From: bin luo @ 2026-12-06 11:04 UTC (permalink / raw)
  To: netdev-bot+sinfo, Bin Luo
  Cc: David Heidelberg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, oe-linux-nfc, netdev, linux-kernel,
	stable

Hi,

Here is the discovery and reproduction summary for this series:

- Patch 1/2 ("nfc: rawsock: serialize SEND_SHUTDOWN and write queue
  teardown"):
  * Discovery: static analysis and AI-assisted code review.
  * Reproduction: the race window between cancel_work_sync() and
    rawsock_write_queue_purge() was confirmed via ftrace on an
    unmodified kernel; the crash itself was not triggered standalone
    without delay injection.  Regression-tested in QEMU KVM (KASAN,
    LOCKDEP, DEBUG_OBJECTS) with tools/testing/selftests/nci/nci_dev
    (8/8 passed) and 600 virtual_ncidev teardown race iterations.

- Patch 2/2 ("nfc: rawsock: avoid synchronous target deactivation in
  rawsock_destruct()"):
  * Discovery: static analysis and AI-assisted code review.
  * Reproduction: triggered live in QEMU KVM on an unmodified kernel
    using /dev/virtual_nci without delay injection (an AF_NFC
    SOCK_SEQPACKET socket sends one frame and closes concurrently with
    the NCI data response), producing the 30-second ndev->rx_wq stall:

      nci: __nci_request: wait_for_completion_interruptible_timeout failed 0

    Verified fixed in QEMU KVM (KASAN, LOCKDEP, DEBUG_OBJECTS) across
    600 virtual_ncidev teardown race iterations (600/600 deactivations,
    0 timeouts), 35 targeted deferred/synchronous deactivation invariant
    tests, and tools/testing/selftests/nci/nci_dev (8/8 passed).

Best regards,
Bin Luo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-06 11:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-06 10:52 [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock Bin Luo via B4 Relay
2026-12-06 10:52 ` [PATCH net v3 1/2] nfc: rawsock: serialize SEND_SHUTDOWN and write queue teardown Bin Luo via B4 Relay
2026-12-06 10:52 ` [PATCH net v3 2/2] nfc: rawsock: avoid synchronous target deactivation in rawsock_destruct() Bin Luo via B4 Relay
2026-12-06 10:57 ` [PATCH net v3 0/2] nfc: rawsock: fix teardown races and destruct-time deactivation deadlock netdev-bot+sinfo
2026-12-06 11:04   ` bin luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®