net/rxrpc/ar-internal.h | 8 ++++++++ net/rxrpc/conn_event.c | 20 ++++++++++++++++---- net/rxrpc/oob.c | 2 ++ 3 files changed, 26 insertions(+), 4 deletions(-)
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;
}
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.
Hi, Found by code inspection, then reproduced with a local PoC on a Linux 7.0-rc3 KASAN/QEMU kernel. A userspace fake RxGK peer sent 20,000 connection-level CHALLENGE packets to a client socket that had RXRPC_MANAGE_RESPONSE set and never called recvmsg(). Unpatched, /proc/net/rxrpc/stats went from rxb=0 to rxb=20000: all 20,000 CHALLENGE skbs were retained on recvmsg_oobq (each also pinning a connection reference). There is no crash or KASAN report; the symptom is unbounded skb memory retention. With the per-connection cap applied, the same test stops at rxb=4. Thanks, Lin Ma
© 2016 - 2026 Red Hat, Inc.