From: Sechang Lim <rhkrqnwk98@gmail.com>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, edumazet@kernel.org,
ncardwell@google.com, kuniyu@google.com,
john.fastabend@gmail.com, jakub@cloudflare.com,
jiayuan.chen@linux.dev, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org
Subject: [PATCH bpf] bpf, sockmap: Don't replace a ULP's sk_prot when leaving a sockmap
Date: Mon, 30 Nov 2026 05:56:46 +0000 [thread overview]
Message-ID: <20261130055650.686483-1-rhkrqnwk98@gmail.com> (raw)
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 <rhkrqnwk98@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
reply other threads:[~2026-11-30 5:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130055650.686483-1-rhkrqnwk98@gmail.com \
--to=rhkrqnwk98@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jakub@cloudflare.com \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox