Skip to content

Commit 4da6a19

Browse files
jrfastabborkmann
authored andcommitted
bpf: Sockmap/tls, during free we may call tcp_bpf_unhash() in loop
When a sockmap is free'd and a socket in the map is enabled with tls we tear down the bpf context on the socket, the psock struct and state, and then call tcp_update_ulp(). The tcp_update_ulp() call is to inform the tls stack it needs to update its saved sock ops so that when the tls socket is later destroyed it doesn't try to call the now destroyed psock hooks. This is about keeping stacked ULPs in good shape so they always have the right set of stacked ops. However, recently unhash() hook was removed from TLS side. But, the sockmap/bpf side is not doing any extra work to update the unhash op when is torn down instead expecting TLS side to manage it. So both TLS and sockmap believe the other side is managing the op and instead no one updates the hook so it continues to point at tcp_bpf_unhash(). When unhash hook is called we call tcp_bpf_unhash() which detects the psock has already been destroyed and calls sk->sk_prot_unhash() which calls tcp_bpf_unhash() yet again and so on looping and hanging the core. To fix have sockmap tear down logic fixup the stale pointer. Fixes: 5d92e63 ("net/tls: partially revert fix transition through disconnect with close") Reported-by: [email protected] Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Jakub Sitnicki <[email protected]> Acked-by: Song Liu <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/bpf/[email protected]
1 parent 0af2ffc commit 4da6a19

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/linux/skmsg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ static inline void sk_psock_update_proto(struct sock *sk,
358358
static inline void sk_psock_restore_proto(struct sock *sk,
359359
struct sk_psock *psock)
360360
{
361+
sk->sk_prot->unhash = psock->saved_unhash;
361362
sk->sk_write_space = psock->saved_write_space;
362363

363364
if (psock->sk_proto) {

0 commit comments

Comments
 (0)