Netdev List
 help / color / mirror / Atom feed
* [PATCH net] rxrpc: Bound the OOB challenge queue per connection
@ 2026-11-23  1:13 Lin Ma
  2026-11-23  1:18 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Ma @ 2026-11-23  1:13 UTC (permalink / raw)
  To: David Howells, Marc Dionne; +Cc: netdev, linux-afs, linux-kernel, Lin Ma

rxrpc_notify_socket_oob() adds CHALLENGE packets to the owning socket's
recvmsg_oobq without any limit.  A peer that keeps sending CHALLENGEs on
an existing connection can therefore grow that queue, and the
pending_oobq tree it feeds, without bound if the socket owner never
reads or responds to them.  Each queued skb also holds a reference to
the connection.

A connection cannot make progress until a CHALLENGE is answered, so
there is no point in retaining an arbitrarily deep backlog of them.
Count the outstanding OOB skbs against the connection and drop new
CHALLENGEs once a small limit is reached.  The count is dropped when the
skb is finally freed, whether by the userspace response path, the kernel
OOB API or socket teardown.

Dropping the packet consumes it without sending a reject, so a flood
does not abort the connection; if the application cannot keep up, the
existing call and connection timeouts still apply.

Fixes: 5800b1cf3fd8 ("rxrpc: Allow CHALLENGEs to the passed to the app for a RESPONSE")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
 net/rxrpc/ar-internal.h |  8 ++++++++
 net/rxrpc/conn_event.c  | 20 ++++++++++++++++----
 net/rxrpc/oob.c         |  2 ++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 865f05fe37ab..1eabf1ad5b28 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -534,6 +534,13 @@ struct rxrpc_bundle {
 	struct rxrpc_connection	*conns[4];	/* The connections in the bundle (max 4) */
 };
 
+/*
+ * Maximum number of out-of-band messages that may be queued against a
+ * connection.  A connection cannot make progress while a CHALLENGE is
+ * outstanding, so a deeper queue only represents a peer flooding us.
+ */
+#define RXRPC_OOB_MAX_QUEUED	4
+
 /*
  * RxRPC connection definition
  * - matched by { local, peer, epoch, conn_id, direction }
@@ -575,6 +582,7 @@ struct rxrpc_connection {
 	struct list_head	proc_link;	/* link in procfs list */
 	struct list_head	link;		/* link in master connection list */
 	struct sk_buff_head	rx_queue;	/* received conn-level packets */
+	atomic_t		n_oobq;		/* Number of OOB messages queued */
 	struct page_frag_cache	tx_data_alloc;	/* Tx DATA packet allocation */
 	struct mutex		tx_data_alloc_lock;
 
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index 611c790bc6d0..8665e5f7770d 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -436,7 +436,7 @@ static bool rxrpc_post_challenge(struct rxrpc_connection *conn,
 	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
 	struct rxrpc_call *call = NULL;
 	struct rxrpc_sock *rx;
-	bool respond = false, queued = false;
+	bool respond = false, queued = false, drop = false;
 
 	sp->chall.conn =
 		rxrpc_get_connection(conn, rxrpc_conn_get_challenge_input);
@@ -471,13 +471,25 @@ static bool rxrpc_post_challenge(struct rxrpc_connection *conn,
 		return false;
 	}
 
-	if (call)
-		queued = rxrpc_notify_socket_oob(call, skb);
+	if (call) {
+		/* A connection can only make progress by answering one
+		 * CHALLENGE at a time, so don't let a peer pile an unbounded
+		 * number of them up on the socket queue.
+		 */
+		if (atomic_inc_return(&conn->n_oobq) <= RXRPC_OOB_MAX_QUEUED) {
+			queued = rxrpc_notify_socket_oob(call, skb);
+			if (!queued)
+				atomic_dec(&conn->n_oobq);
+		} else {
+			atomic_dec(&conn->n_oobq);
+			drop = true;
+		}
+	}
 	rcu_read_unlock();
 	if (call && !queued) {
 		rxrpc_put_connection(conn, rxrpc_conn_put_challenge_input);
 		sp->chall.conn = NULL;
-		return false;
+		return drop;	/* Silently consume a challenge we dropped. */
 	}
 
 	if (!call)
diff --git a/net/rxrpc/oob.c b/net/rxrpc/oob.c
index c80ee2487d09..a126296866fa 100644
--- a/net/rxrpc/oob.c
+++ b/net/rxrpc/oob.c
@@ -215,6 +215,7 @@ static int rxrpc_respond_to_oob(struct rxrpc_sock *rx,
 
 	switch (skb->mark) {
 	case RXRPC_OOB_CHALLENGE:
+		atomic_dec(&sp->chall.conn->n_oobq);
 		rxrpc_put_connection(sp->chall.conn, rxrpc_conn_put_oob);
 		break;
 	}
@@ -329,6 +330,7 @@ void rxrpc_kernel_free_oob(struct sk_buff *oob)
 
 	switch (oob->mark) {
 	case RXRPC_OOB_CHALLENGE:
+		atomic_dec(&sp->chall.conn->n_oobq);
 		rxrpc_put_connection(sp->chall.conn, rxrpc_conn_put_oob);
 		break;
 	}


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

end of thread, other threads:[~2026-11-23  1:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  1:13 [PATCH net] rxrpc: Bound the OOB challenge queue per connection Lin Ma
2026-11-23  1:18 ` netdev-bot+sinfo

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