From: sashiko-bot@kernel.org
To: "Jakub Kicinski" <kuba@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 1/5] tls: reject the combination of TLS and sockmap
Date: Mon, 15 Jun 2026 01:41:23 +0000 [thread overview]
Message-ID: <20260615014123.9EC871F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260614014102.461064-2-kuba@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The patch attempts to reject the combination of TLS and sockmap during key configuration, but leaves a critical vulnerability where attaching the TLS ULP to a socket already in a sockmap causes global protocol state corruption, infinite loops in unrelated sockets, and silently bypasses BPF sk_msg policies.
--
commit 12fd2fff4db720c6f124011a38950efdbcd77414
Author: Jakub Kicinski <kuba@kernel.org>
tls: reject the combination of TLS and sockmap
This commit attempts to reject the combination of TLS and sockmap by
returning -EINVAL in do_tls_setsockopt_conf() if a psock is attached.
The goal is to prevent latent bugs while removing dead code.
> diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
> index 13c88a7b8787d..8e7ba018988d2 100644
> --- a/net/tls/tls_main.c
> +++ b/net/tls/tls_main.c
> @@ -643,6 +643,17 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
[ ... ]
> int rc = 0;
> int conf;
>
> + /* TLS and sockmap are mutually exclusive. A socket already in a
> + * sockmap (i.e. with a psock attached) cannot be upgraded to TLS.
> + * sockmap rejects TLS sockets already (see sk_psock_init()).
> + */
> + rcu_read_lock();
> + if (sk_psock(sk)) {
> + rcu_read_unlock();
> + return -EINVAL;
> + }
> + rcu_read_unlock();
> +
[Severity: Critical]
This isn't a bug introduced by this patch, but does this check happen too
late to prevent global protocol state corruption?
If an unprivileged user adds an established TCP socket to a sockmap, the
socket's sk_prot is changed to tcp_bpf_prots. If they then attach the TLS ULP,
tls_init() executes and immediately calls tls_build_proto() before this
key configuration check is ever reached:
net/tls/tls_main.c:tls_init() {
...
tls_build_proto(sk);
...
}
This function reads the socket's current sk_prot and uses it to rebuild the
global tls_prots array:
net/tls/tls_main.c:tls_build_proto() {
...
struct proto *prot = READ_ONCE(sk->sk_prot);
...
build_protos(tls_prots[TLSV4], prot);
...
}
Because sk_prot is tcp_bpf_prots, the unhash handler in the tls_prots array
is permanently overwritten with sock_map_unhash.
Any subsequent normal TLS socket will inherit this corrupted global array.
When the normal TLS socket is closed, sock_map_unhash() is invoked. Since
the normal socket has no psock, it attempts to fall back to the original
unhash function, leading to an infinite retry loop:
net/core/sock_map.c:sock_map_unhash() {
...
saved_unhash = READ_ONCE(sk->sk_prot)->unhash;
if (unlikely(saved_unhash == sock_map_unhash))
goto retry;
...
}
Because sk->sk_prot points to the corrupted tls_prots array, it reads
sock_map_unhash again, causing a kernel hard lockup.
Could a check be placed in tls_init() or tcp_set_ulp() instead, to prevent
ULP attachment entirely before tls_build_proto() is called?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260614014102.461064-1-kuba@kernel.org?part=1
next prev parent reply other threads:[~2026-06-15 1:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 1:40 [PATCH net-next 0/5] tls: reject the combination of TLS and sockmap Jakub Kicinski
2026-06-14 1:40 ` [PATCH net-next 1/5] " Jakub Kicinski
2026-06-14 8:09 ` Paolo Abeni
2026-06-14 19:12 ` Jakub Sitnicki
2026-06-15 18:20 ` Jakub Kicinski
2026-06-15 1:41 ` sashiko-bot [this message]
2026-06-15 18:45 ` Jakub Sitnicki
2026-06-15 22:00 ` Sabrina Dubroca
2026-06-14 1:40 ` [PATCH net-next 2/5] tls: remove dead sockmap (psock) handling from the SW path Jakub Kicinski
2026-06-15 14:55 ` Jakub Sitnicki
2026-06-15 22:20 ` Sabrina Dubroca
2026-06-14 1:40 ` [PATCH net-next 3/5] selftests/bpf: remove sockmap + ktls tests Jakub Kicinski
2026-06-16 10:04 ` Jakub Sitnicki
2026-06-14 1:40 ` [PATCH net-next 4/5] selftests/bpf: drop the unused kTLS program from test_sockmap Jakub Kicinski
2026-06-14 1:41 ` [PATCH net-next 5/5] selftests/bpf: test that TLS crypto is rejected on a sockmap socket Jakub Kicinski
2026-06-16 16:10 ` [PATCH net-next 0/5] tls: reject the combination of TLS and sockmap patchwork-bot+netdevbpf
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=20260615014123.9EC871F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.