diff mbox series

[net,2/2] rxrpc: Fix the rxrpc_connection attend queue handling

Message ID 20250203110307.7265-3-dhowells@redhat.com (mailing list archive)
State Accepted
Commit 4241a702e0d0c2ca9364cfac08dbf134264962de
Delegated to: Netdev Maintainers
Headers show
Series rxrpc: Miscellaneous fixes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 26 (+1) this patch: 26 (+1)
netdev/cc_maintainers warning 4 maintainers not CCed: rostedt@goodmis.org linux-trace-kernel@vger.kernel.org mathieu.desnoyers@efficios.com mhiramat@kernel.org
netdev/build_clang success Errors and warnings before: 39 this patch: 39
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch warning WARNING: line length of 91 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-02-04--00-00 (tests: 886)

Commit Message

David Howells Feb. 3, 2025, 11:03 a.m. UTC
The rxrpc_connection attend queue is never used because conn::attend_link
is never initialised and so is always NULL'd out and thus always appears to
be busy.  This requires the following fix:

 (1) Fix this the attend queue problem by initialising conn::attend_link.

And, consequently, two further fixes for things masked by the above bug:

 (2) Fix rxrpc_input_conn_event() to handle being invoked with a NULL
     sk_buff pointer - something that can now happen with the above change.

 (3) Fix the RXRPC_SKB_MARK_SERVICE_CONN_SECURED message to carry a pointer
     to the connection and a ref on it.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Paolo Abeni <pabeni@redhat.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
---
 include/trace/events/rxrpc.h |  1 +
 net/rxrpc/conn_event.c       | 17 ++++++++++-------
 net/rxrpc/conn_object.c      |  1 +
 3 files changed, 12 insertions(+), 7 deletions(-)

Comments

Paolo Abeni Feb. 4, 2025, 11:12 a.m. UTC | #1
On 2/3/25 12:03 PM, David Howells wrote:
> The rxrpc_connection attend queue is never used because conn::attend_link
> is never initialised and so is always NULL'd out and thus always appears to
> be busy.  This requires the following fix:
> 
>  (1) Fix this the attend queue problem by initialising conn::attend_link.
> 
> And, consequently, two further fixes for things masked by the above bug:
> 
>  (2) Fix rxrpc_input_conn_event() to handle being invoked with a NULL
>      sk_buff pointer - something that can now happen with the above change.
> 
>  (3) Fix the RXRPC_SKB_MARK_SERVICE_CONN_SECURED message to carry a pointer
>      to the connection and a ref on it.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Eric Dumazet <edumazet@google.com>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: Simon Horman <horms@kernel.org>
> cc: linux-afs@lists.infradead.org
> cc: netdev@vger.kernel.org

A couple of minor nits: I think this deserves a 'Fixes' tag, and
possibly split into separate patches to address the reported problems
individually.

Thanks,

Paolo
David Howells Feb. 4, 2025, 2:09 p.m. UTC | #2
Paolo Abeni <pabeni@redhat.com> wrote:

> A couple of minor nits: I think this deserves a 'Fixes' tag,

Fixes: f2cce89a074e ("rxrpc: Implement a mechanism to send an event notification to a connection")

> and possibly split into separate patches to address the reported problems
> individually.

I can do that if you really want.

David
Paolo Abeni Feb. 4, 2025, 2:34 p.m. UTC | #3
On 2/4/25 3:09 PM, David Howells wrote:
> Paolo Abeni <pabeni@redhat.com> wrote:
> 
>> A couple of minor nits: I think this deserves a 'Fixes' tag,
> 
> Fixes: f2cce89a074e ("rxrpc: Implement a mechanism to send an event notification to a connection")
> 
>> and possibly split into separate patches to address the reported problems
>> individually.
> 
> I can do that if you really want.

I guess we are all better off without the need for a repost. I'm
applying it as-is.

/P
David Howells Feb. 4, 2025, 3:46 p.m. UTC | #4
Paolo Abeni <pabeni@redhat.com> wrote:

> I guess we are all better off without the need for a repost. I'm
> applying it as-is.

Thanks :-)

I think that patch 1 (that I dropped) is probably correct, but that it brings
a further bug to the fore, so I'll track that down before resubmitting.

David
diff mbox series

Patch

diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h
index 2f119d18a061..cad50d91077e 100644
--- a/include/trace/events/rxrpc.h
+++ b/include/trace/events/rxrpc.h
@@ -219,6 +219,7 @@ 
 	EM(rxrpc_conn_get_conn_input,		"GET inp-conn") \
 	EM(rxrpc_conn_get_idle,			"GET idle    ") \
 	EM(rxrpc_conn_get_poke_abort,		"GET pk-abort") \
+	EM(rxrpc_conn_get_poke_secured,		"GET secured ") \
 	EM(rxrpc_conn_get_poke_timer,		"GET poke    ") \
 	EM(rxrpc_conn_get_service_conn,		"GET svc-conn") \
 	EM(rxrpc_conn_new_client,		"NEW client  ") \
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index d93b041c4894..4d9c5e21ba78 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -270,6 +270,7 @@  static int rxrpc_process_event(struct rxrpc_connection *conn,
 			 * we've already received the packet, put it on the
 			 * front of the queue.
 			 */
+			sp->conn = rxrpc_get_connection(conn, rxrpc_conn_get_poke_secured);
 			skb->mark = RXRPC_SKB_MARK_SERVICE_CONN_SECURED;
 			rxrpc_get_skb(skb, rxrpc_skb_get_conn_secured);
 			skb_queue_head(&conn->local->rx_queue, skb);
@@ -435,14 +436,16 @@  void rxrpc_input_conn_event(struct rxrpc_connection *conn, struct sk_buff *skb)
 	if (test_and_clear_bit(RXRPC_CONN_EV_ABORT_CALLS, &conn->events))
 		rxrpc_abort_calls(conn);
 
-	switch (skb->mark) {
-	case RXRPC_SKB_MARK_SERVICE_CONN_SECURED:
-		if (conn->state != RXRPC_CONN_SERVICE)
-			break;
+	if (skb) {
+		switch (skb->mark) {
+		case RXRPC_SKB_MARK_SERVICE_CONN_SECURED:
+			if (conn->state != RXRPC_CONN_SERVICE)
+				break;
 
-		for (loop = 0; loop < RXRPC_MAXCALLS; loop++)
-			rxrpc_call_is_secure(conn->channels[loop].call);
-		break;
+			for (loop = 0; loop < RXRPC_MAXCALLS; loop++)
+				rxrpc_call_is_secure(conn->channels[loop].call);
+			break;
+		}
 	}
 
 	/* Process delayed ACKs whose time has come. */
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 7eba4d7d9a38..2f1fd1e2e7e4 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -67,6 +67,7 @@  struct rxrpc_connection *rxrpc_alloc_connection(struct rxrpc_net *rxnet,
 		INIT_WORK(&conn->destructor, rxrpc_clean_up_connection);
 		INIT_LIST_HEAD(&conn->proc_link);
 		INIT_LIST_HEAD(&conn->link);
+		INIT_LIST_HEAD(&conn->attend_link);
 		mutex_init(&conn->security_lock);
 		mutex_init(&conn->tx_data_alloc_lock);
 		skb_queue_head_init(&conn->rx_queue);