* [PATCH net v2 1/2] rxrpc: Fix bug due to prealloc collision
2025-07-08 21:15 [PATCH net v2 0/2] rxrpc: Miscellaneous fixes David Howells
@ 2025-07-08 21:15 ` David Howells
2025-07-08 21:15 ` [PATCH net v2 2/2] rxrpc: Fix oops due to non-existence of prealloc backlog struct David Howells
2025-07-10 3:20 ` [PATCH net v2 0/2] rxrpc: Miscellaneous fixes patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: David Howells @ 2025-07-08 21:15 UTC (permalink / raw)
To: netdev
Cc: David Howells, Marc Dionne, Jakub Kicinski, David S. Miller,
Eric Dumazet, Paolo Abeni, linux-afs, linux-kernel,
Junvyyang, Tencent Zhuque Lab, LePremierHomme, Simon Horman
When userspace is using AF_RXRPC to provide a server, it has to preallocate
incoming calls and assign to them call IDs that will be used to thread
related recvmsg() and sendmsg() together. The preallocated call IDs will
automatically be attached to calls as they come in until the pool is empty.
To the kernel, the call IDs are just arbitrary numbers, but userspace can
use the call ID to hold a pointer to prepared structs. In any case, the
user isn't permitted to create two calls with the same call ID (call IDs
become available again when the call ends) and EBADSLT should result from
sendmsg() if an attempt is made to preallocate a call with an in-use call
ID.
However, the cleanup in the error handling will trigger both assertions in
rxrpc_cleanup_call() because the call isn't marked complete and isn't
marked as having been released.
Fix this by setting the call state in rxrpc_service_prealloc_one() and then
marking it as being released before calling the cleanup function.
Fixes: 00e907127e6f ("rxrpc: Preallocate peers, conns and calls for incoming service requests")
Reported-by: Junvyyang, Tencent Zhuque Lab <zhuque@tencent.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: LePremierHomme <kwqcheii@proton.me>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
---
Notes:
Changes
=======
ver #2)
- Don't need to double-set RXRPC_CALL_RELEASED.
net/rxrpc/call_accept.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index a4b363b47cca..7271977b1683 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -149,6 +149,7 @@ static int rxrpc_service_prealloc_one(struct rxrpc_sock *rx,
id_in_use:
write_unlock(&rx->call_lock);
+ rxrpc_prefail_call(call, RXRPC_CALL_LOCAL_ERROR, -EBADSLT);
rxrpc_cleanup_call(call);
_leave(" = -EBADSLT");
return -EBADSLT;
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net v2 2/2] rxrpc: Fix oops due to non-existence of prealloc backlog struct
2025-07-08 21:15 [PATCH net v2 0/2] rxrpc: Miscellaneous fixes David Howells
2025-07-08 21:15 ` [PATCH net v2 1/2] rxrpc: Fix bug due to prealloc collision David Howells
@ 2025-07-08 21:15 ` David Howells
2025-07-10 3:20 ` [PATCH net v2 0/2] rxrpc: Miscellaneous fixes patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: David Howells @ 2025-07-08 21:15 UTC (permalink / raw)
To: netdev
Cc: David Howells, Marc Dionne, Jakub Kicinski, David S. Miller,
Eric Dumazet, Paolo Abeni, linux-afs, linux-kernel,
Junvyyang, Tencent Zhuque Lab, LePremierHomme, Willy Tarreau,
Simon Horman
If an AF_RXRPC service socket is opened and bound, but calls are
preallocated, then rxrpc_alloc_incoming_call() will oops because the
rxrpc_backlog struct doesn't get allocated until the first preallocation is
made.
Fix this by returning NULL from rxrpc_alloc_incoming_call() if there is no
backlog struct. This will cause the incoming call to be aborted.
Reported-by: Junvyyang, Tencent Zhuque Lab <zhuque@tencent.com>
Suggested-by: Junvyyang, Tencent Zhuque Lab <zhuque@tencent.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: LePremierHomme <kwqcheii@proton.me>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Willy Tarreau <w@1wt.eu>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
---
net/rxrpc/call_accept.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index 7271977b1683..49fccee1a726 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -255,6 +255,9 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx,
unsigned short call_tail, conn_tail, peer_tail;
unsigned short call_count, conn_count;
+ if (!b)
+ return NULL;
+
/* #calls >= #conns >= #peers must hold true. */
call_head = smp_load_acquire(&b->call_backlog_head);
call_tail = b->call_backlog_tail;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2 0/2] rxrpc: Miscellaneous fixes
2025-07-08 21:15 [PATCH net v2 0/2] rxrpc: Miscellaneous fixes David Howells
2025-07-08 21:15 ` [PATCH net v2 1/2] rxrpc: Fix bug due to prealloc collision David Howells
2025-07-08 21:15 ` [PATCH net v2 2/2] rxrpc: Fix oops due to non-existence of prealloc backlog struct David Howells
@ 2025-07-10 3:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-10 3:20 UTC (permalink / raw)
To: David Howells
Cc: netdev, marc.dionne, kuba, davem, edumazet, pabeni, linux-afs,
linux-kernel
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 8 Jul 2025 22:15:02 +0100 you wrote:
> Here are some miscellaneous fixes for rxrpc:
>
> (1) Fix assertion failure due to preallocation collision.
>
> (2) Fix oops due to prealloc backlog struct not yet having been allocated
> if no service calls have yet been preallocated.
>
> [...]
Here is the summary with links:
- [net,v2,1/2] rxrpc: Fix bug due to prealloc collision
https://git.kernel.org/netdev/net/c/69e4186773c6
- [net,v2,2/2] rxrpc: Fix oops due to non-existence of prealloc backlog struct
https://git.kernel.org/netdev/net/c/880a88f318cf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread