From: Henry Martin <bsdhenrymartin@gmail.com>
To: netdev@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>,
linux-afs@lists.infradead.org,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-kernel@vger.kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>
Subject: [PATCH 2/3] rxrpc: wait for deferred conn destruction before conn_proc_list check
Date: Sun, 23 Aug 2026 13:53:17 +0800 [thread overview]
Message-ID: <20260823055318.371374-3-bsdhenrymartin@gmail.com> (raw)
In-Reply-To: <20260823055318.371374-1-bsdhenrymartin@gmail.com>
rxrpc_destroy_all_connections() flushes rxrpc_workqueue and then
immediately asserts that rxnet->conn_proc_list is empty. However,
connection destruction is normally deferred to system_wq: the
final-ACK timer is still pending when the last ref is dropped, so
rxrpc_put_connection() schedules conn->destructor instead of running
it inline. conn->proc_link is only removed by the deferred
destructor (rxrpc_clean_up_connection()), which the
flush_workqueue(rxrpc_workqueue) call does not cover - so the
assertion can fire on a perfectly healthy intermediate state:
rxrpc: Assertion failed
kernel BUG at net/rxrpc/conn_object.c:488!
Workqueue: netns cleanup_net
The BUG kills the cleanup_net kworker mid-teardown, leaving the
netns half-destroyed and potentially wedging later netns operations.
This is easily reachable from an unprivileged userns+netns running
loopback AF_RXRPC traffic.
The existing wait_var_event() on nr_conns is exactly the right
synchronization: nr_conns only reaches zero after every destructor
and RCU free has completed, which implies proc_link has been removed
from every connection. It is, however, placed *after* the assertion
it is meant to make reliable. Move it between the service_conns
leak check (whose outcome is already final once the reaper has been
flushed) and the conn_proc_list assertion.
This also silences the spurious "AF_RXRPC: Leaked peer" messages
seen during netns teardown, which share the same root cause: peer
references are dropped by the same deferred destructors.
Found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
net/rxrpc/conn_object.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 0ece717db0f85..df3f92b1a42e9 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -485,11 +485,13 @@ void rxrpc_destroy_all_connections(struct rxrpc_net *rxnet)
write_unlock(&rxnet->conn_lock);
BUG_ON(leak);
- ASSERT(list_empty(&rxnet->conn_proc_list));
-
- /* We need to wait for the connections to be destroyed by RCU as they
- * pin things that we still need to get rid of.
+ /* Connection destruction is normally deferred to system_wq because
+ * the final-ACK timer is still pending when the last ref is dropped.
+ * Wait for the deferred destructors (and the RCU frees) to complete
+ * before checking conn_proc_list; they remove conns from it.
*/
wait_var_event(&rxnet->nr_conns, !atomic_read(&rxnet->nr_conns));
+
+ ASSERT(list_empty(&rxnet->conn_proc_list));
_leave("");
}
--
2.43.0
next prev parent reply other threads:[~2026-08-23 5:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 5:53 [PATCH 0/3] rxrpc: fix three bugs found by autokbug fuzzing Henry Martin
2026-08-23 5:53 ` [PATCH 1/3] rxrpc: fix stack OOB read in TLP soft-ACK processing Henry Martin
2026-08-23 5:53 ` Henry Martin [this message]
2026-08-23 5:53 ` [PATCH 3/3] rxrpc: recheck RXRPC_CALL_TX_NO_MORE after sleeping in rxrpc_send_data() Henry Martin
-- strict thread matches above, loose matches on Subject: below --
2026-08-03 7:33 [PATCH 0/3] rxrpc: fix three bugs found by autokbug fuzzing Henry Martin
2026-08-03 7:33 ` [PATCH 2/3] rxrpc: wait for deferred conn destruction before conn_proc_list check Henry Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260823055318.371374-3-bsdhenrymartin@gmail.com \
--to=bsdhenrymartin@gmail.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox