mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
tls: remove dead sockmap (psock) handling from the SW path
TLS and sockmap are now mutually exclusive. Try to delete the code from sendmsg and recvmsg path which is now obviously dead. The main goal is to delete enough code for AI security scanners to no longer bother us with sockmap related bugs. At the same time retain the code in case someone has the cycles to fix all of this and make the integration work, again. If the integration does not get restored we can wipe the rest of the skmsg code from TLS in two or three releases. The changes on the Tx side are deeper since that's where most of the bugs are, Rx side simply takes the data from sockmap and gives it to the user. On Tx split record handling and rolling back the iterator were the two problem areas. Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/20260614014102.461064-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -544,15 +544,6 @@ static inline void psock_progs_drop(struct sk_psock_progs *progs)
|
||||
psock_set_prog(&progs->skb_verdict, NULL);
|
||||
}
|
||||
|
||||
int sk_psock_tls_strp_read(struct sk_psock *psock, struct sk_buff *skb);
|
||||
|
||||
static inline bool sk_psock_strp_enabled(struct sk_psock *psock)
|
||||
{
|
||||
if (!psock)
|
||||
return false;
|
||||
return !!psock->saved_data_ready;
|
||||
}
|
||||
|
||||
/* for tcp only, sk is locked */
|
||||
static inline ssize_t sk_psock_msg_inq(struct sock *sk)
|
||||
{
|
||||
|
||||
+3
-49
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <net/sock.h>
|
||||
#include <net/tcp.h>
|
||||
#include <net/tls.h>
|
||||
#include <trace/events/sock.h>
|
||||
|
||||
static bool sk_msg_try_coalesce_ok(struct sk_msg *msg, int elem_first_coalesce)
|
||||
@@ -992,41 +991,6 @@ static int sk_psock_skb_redirect(struct sk_psock *from, struct sk_buff *skb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sk_psock_tls_verdict_apply(struct sk_buff *skb,
|
||||
struct sk_psock *from, int verdict)
|
||||
{
|
||||
switch (verdict) {
|
||||
case __SK_REDIRECT:
|
||||
sk_psock_skb_redirect(from, skb);
|
||||
break;
|
||||
case __SK_PASS:
|
||||
case __SK_DROP:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int sk_psock_tls_strp_read(struct sk_psock *psock, struct sk_buff *skb)
|
||||
{
|
||||
struct bpf_prog *prog;
|
||||
int ret = __SK_PASS;
|
||||
|
||||
rcu_read_lock();
|
||||
prog = READ_ONCE(psock->progs.stream_verdict);
|
||||
if (likely(prog)) {
|
||||
skb->sk = psock->sk;
|
||||
skb_dst_drop(skb);
|
||||
skb_bpf_redirect_clear(skb);
|
||||
ret = bpf_prog_run_pin_on_cpu(prog, skb);
|
||||
ret = sk_psock_map_verd(ret, skb_bpf_redirect_fetch(skb));
|
||||
skb->sk = NULL;
|
||||
}
|
||||
sk_psock_tls_verdict_apply(skb, psock, ret);
|
||||
rcu_read_unlock();
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sk_psock_tls_strp_read);
|
||||
|
||||
static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
|
||||
int verdict)
|
||||
{
|
||||
@@ -1167,13 +1131,9 @@ static void sk_psock_strp_data_ready(struct sock *sk)
|
||||
rcu_read_lock();
|
||||
psock = sk_psock(sk);
|
||||
if (likely(psock)) {
|
||||
if (tls_sw_has_ctx_rx(sk)) {
|
||||
psock->saved_data_ready(sk);
|
||||
} else {
|
||||
read_lock_bh(&sk->sk_callback_lock);
|
||||
strp_data_ready(&psock->strp);
|
||||
read_unlock_bh(&sk->sk_callback_lock);
|
||||
}
|
||||
read_lock_bh(&sk->sk_callback_lock);
|
||||
strp_data_ready(&psock->strp);
|
||||
read_unlock_bh(&sk->sk_callback_lock);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
@@ -1275,12 +1235,6 @@ static void sk_psock_verdict_data_ready(struct sock *sk)
|
||||
trace_sk_data_ready(sk);
|
||||
|
||||
rcu_read_lock();
|
||||
psock = sk_psock(sk);
|
||||
if (psock && tls_sw_has_ctx_rx(sk)) {
|
||||
psock->saved_data_ready(sk);
|
||||
rcu_read_unlock();
|
||||
return;
|
||||
}
|
||||
sock = READ_ONCE(sk->sk_socket);
|
||||
if (likely(sock))
|
||||
ops = READ_ONCE(sock->ops);
|
||||
|
||||
+1
-7
@@ -402,7 +402,6 @@ static __poll_t tls_sk_poll(struct file *file, struct socket *sock,
|
||||
struct tls_sw_context_rx *ctx;
|
||||
struct tls_context *tls_ctx;
|
||||
struct sock *sk = sock->sk;
|
||||
struct sk_psock *psock;
|
||||
__poll_t mask = 0;
|
||||
u8 shutdown;
|
||||
int state;
|
||||
@@ -416,17 +415,12 @@ static __poll_t tls_sk_poll(struct file *file, struct socket *sock,
|
||||
|
||||
tls_ctx = tls_get_ctx(sk);
|
||||
ctx = tls_sw_ctx_rx(tls_ctx);
|
||||
psock = sk_psock_get(sk);
|
||||
|
||||
if ((skb_queue_empty_lockless(&ctx->rx_list) &&
|
||||
!tls_strp_msg_ready(ctx) &&
|
||||
sk_psock_queue_empty(psock)) ||
|
||||
!tls_strp_msg_ready(ctx)) ||
|
||||
READ_ONCE(ctx->key_update_pending))
|
||||
mask &= ~(EPOLLIN | EPOLLRDNORM);
|
||||
|
||||
if (psock)
|
||||
sk_psock_put(sk, psock);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
+27
-372
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user