A socket can get the TLS ULP after it was added to a sockmap. If the map has an sk_skb program, removing the socket from it calls tcp_bpf_update_proto() with restore=false, which puts a tcp_bpf proto in sk->sk_prot over the TLS one. When the psock is dropped, the restore path sees the ULP and only calls tcp_update_ulp(), which updates the TLS context but leaves sk->sk_prot alone. close() then enters sock_map_close() with no psock, reads sock_map_close() again from sk->sk_prot->close and retries forever. The task can't be killed and the socket is never freed. Don't replace sk->sk_prot when a ULP is installed. Fixes: e34a07c0ae39 ("sock: redo the psock vs ULP protection check") Signed-off-by: Sechang Lim <rhkr…@gmail.com> --- net/ipv4/tcp_bpf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 788ce08eef4d..035894e5d923 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -810,6 +810,9 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) return 0; } + if (inet_csk_has_ulp(sk)) + return -EINVAL; + if (sk->sk_family == AF_INET6) { if (tcp_bpf_assert_proto_ops(psock->sk_proto)) return -EINVAL;
-- 2.56.1