diff mbox series

[SRU,J,1/1] rxrpc: serialize kernel accept preallocation with socket teardown

Message ID 20261013111947.9321-2-manvi.kardam@canonical.com
State New
Headers show
Series CVE-2026-74436 | expand

Commit Message

Manvi Kardam Oct. 13, 2026, 11:19 a.m. UTC
From: Li Daming <d4n.for.sec@gmail.com>

rxrpc_kernel_charge_accept() reads rx->backlog without any
socket/backlog synchronization and passes that raw pointer into
rxrpc_service_prealloc_one(). A concurrent rxrpc_discard_prealloc()
sets rx->backlog = NULL and frees the backlog rings, so a kernel
preallocation worker can keep using a freed struct rxrpc_backlog
while updating *_backlog_head/tail and array slots.

Serialize the state check and backlog lookup with the socket lock,
and reject kernel preallocation once teardown has disabled
listening or discarded the service backlog.

Fixes: 00e907127e6f ("rxrpc: Preallocate peers, conns and calls for incoming service requests")
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Li Daming <d4n.for.sec@gmail.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Jeffrey Altman <jaltman@auristor.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
cc: stable@kernel.org
Link: https://patch.msgid.link/20260609140911.838677-6-dhowells@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(backported from commit dc175389b18c29a5303ee83169ec653adfae3e17)
[manvikardam: Retain Jammy's rxrpc_user_attach_call_t user_attach_call argument.]
CVE-2026-74436
Signed-off-by: Manvi Kardam <manvi.kardam@canonical.com>
---
 net/rxrpc/call_accept.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

Comments

Roxana Nicolescu Oct. 13, 2026, 1:55 p.m. UTC | #1
On 13/10/2026 13:19, Manvi Kardam via kernel-team wrote:
> From: Li Daming <d4n.for.sec@gmail.com>
>
> rxrpc_kernel_charge_accept() reads rx->backlog without any
> socket/backlog synchronization and passes that raw pointer into
> rxrpc_service_prealloc_one(). A concurrent rxrpc_discard_prealloc()
> sets rx->backlog = NULL and frees the backlog rings, so a kernel
> preallocation worker can keep using a freed struct rxrpc_backlog
> while updating *_backlog_head/tail and array slots.
>
> Serialize the state check and backlog lookup with the socket lock,
> and reject kernel preallocation once teardown has disabled
> listening or discarded the service backlog.
>
> Fixes: 00e907127e6f ("rxrpc: Preallocate peers, conns and calls for incoming service requests")
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Yifan Wu <yifanwucs@gmail.com>
> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
> Reported-by: Xin Liu <bird@lzu.edu.cn>
> Signed-off-by: Li Daming <d4n.for.sec@gmail.com>
> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Jeffrey Altman <jaltman@auristor.com>
> cc: Simon Horman <horms@kernel.org>
> cc: linux-afs@lists.infradead.org
> cc: stable@kernel.org
> Link: https://patch.msgid.link/20260609140911.838677-6-dhowells@redhat.com
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> (backported from commit dc175389b18c29a5303ee83169ec653adfae3e17)
> [manvikardam: Retain Jammy's rxrpc_user_attach_call_t user_attach_call argument.]
> CVE-2026-74436
> Signed-off-by: Manvi Kardam <manvi.kardam@canonical.com>
> ---
>   net/rxrpc/call_accept.c | 28 +++++++++++++++++++++-------
>   1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
> index 658b592e58e0..3cc1010a2a15 100644
> --- a/net/rxrpc/call_accept.c
> +++ b/net/rxrpc/call_accept.c
> @@ -481,14 +481,28 @@ int rxrpc_kernel_charge_accept(struct socket *sock,
>   			       unsigned long user_call_ID, gfp_t gfp,
>   			       unsigned int debug_id)
>   {
> -	struct rxrpc_sock *rx = rxrpc_sk(sock->sk);
> -	struct rxrpc_backlog *b = rx->backlog;
> +	struct rxrpc_backlog *b;
> +	struct rxrpc_sock *rx;
> +	struct sock *sk;
> +	int ret;
> +
> +	sk = sock->sk;
> +	rx = rxrpc_sk(sk);
> +
> +	lock_sock(sk);
> +	if (sk->sk_state != RXRPC_SERVER_LISTENING || !rx->backlog) {
> +		ret = -ESHUTDOWN;
> +		goto out;
> +	}
>   
> -	if (sock->sk->sk_state == RXRPC_CLOSE)
> -		return -ESHUTDOWN;
> +	b = rx->backlog;
> +	ret = rxrpc_service_prealloc_one(rx, b, notify_rx,
> +					 user_attach_call, user_call_ID,
> +					 gfp, debug_id);
> +
> +out:
> +	release_sock(sk);
> +	return ret;
>   
Here empty line
> -	return rxrpc_service_prealloc_one(rx, b, notify_rx,
> -					  user_attach_call, user_call_ID,
> -					  gfp, debug_id);
>   }
>   EXPORT_SYMBOL(rxrpc_kernel_charge_accept);
Functionality wise, it is the correct, but you introduced an empty line 
at the end. See above.
Which also makes the diff between your patch and upstream different,
since the position of the deleted return line is at the end of the 
function.
This is really nitpicking, if you have time, reconsider resubmitting. 
Otherwise, it is fine.
diff mbox series

Patch

diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index 658b592e58e0..3cc1010a2a15 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -481,14 +481,28 @@  int rxrpc_kernel_charge_accept(struct socket *sock,
 			       unsigned long user_call_ID, gfp_t gfp,
 			       unsigned int debug_id)
 {
-	struct rxrpc_sock *rx = rxrpc_sk(sock->sk);
-	struct rxrpc_backlog *b = rx->backlog;
+	struct rxrpc_backlog *b;
+	struct rxrpc_sock *rx;
+	struct sock *sk;
+	int ret;
+
+	sk = sock->sk;
+	rx = rxrpc_sk(sk);
+
+	lock_sock(sk);
+	if (sk->sk_state != RXRPC_SERVER_LISTENING || !rx->backlog) {
+		ret = -ESHUTDOWN;
+		goto out;
+	}
 
-	if (sock->sk->sk_state == RXRPC_CLOSE)
-		return -ESHUTDOWN;
+	b = rx->backlog;
+	ret = rxrpc_service_prealloc_one(rx, b, notify_rx,
+					 user_attach_call, user_call_ID,
+					 gfp, debug_id);
+
+out:
+	release_sock(sk);
+	return ret;
 
-	return rxrpc_service_prealloc_one(rx, b, notify_rx,
-					  user_attach_call, user_call_ID,
-					  gfp, debug_id);
 }
 EXPORT_SYMBOL(rxrpc_kernel_charge_accept);