net: remove SOCK_SUPPORT_ZC from sockmap

sockmap replaces ->sk_prot with its own callbacks, we should remove
SOCK_SUPPORT_ZC as the new proto doesn't support msghdr::ubuf_info.

Cc: <stable@vger.kernel.org> # 6.0
Reported-by: Jakub Kicinski <kuba@kernel.org>
Fixes: e993ffe3da ("net: flag sockets supporting msghdr originated zerocopy")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Pavel Begunkov 2022-10-27 00:25:57 +01:00 committed by Jakub Kicinski
parent 8f279fb00b
commit fee9ac0664
4 changed files with 15 additions and 8 deletions

View File

@ -1889,6 +1889,13 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);
void sock_kzfree_s(struct sock *sk, void *mem, int size); void sock_kzfree_s(struct sock *sk, void *mem, int size);
void sk_send_sigurg(struct sock *sk); void sk_send_sigurg(struct sock *sk);
static inline void sock_replace_proto(struct sock *sk, struct proto *proto)
{
if (sk->sk_socket)
clear_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
WRITE_ONCE(sk->sk_prot, proto);
}
struct sockcm_cookie { struct sockcm_cookie {
u64 transmit_time; u64 transmit_time;
u32 mark; u32 mark;

View File

@ -607,7 +607,7 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
} else { } else {
sk->sk_write_space = psock->saved_write_space; sk->sk_write_space = psock->saved_write_space;
/* Pairs with lockless read in sk_clone_lock() */ /* Pairs with lockless read in sk_clone_lock() */
WRITE_ONCE(sk->sk_prot, psock->sk_proto); sock_replace_proto(sk, psock->sk_proto);
} }
return 0; return 0;
} }
@ -620,7 +620,7 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
} }
/* Pairs with lockless read in sk_clone_lock() */ /* Pairs with lockless read in sk_clone_lock() */
WRITE_ONCE(sk->sk_prot, &tcp_bpf_prots[family][config]); sock_replace_proto(sk, &tcp_bpf_prots[family][config]);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(tcp_bpf_update_proto); EXPORT_SYMBOL_GPL(tcp_bpf_update_proto);

View File

@ -141,14 +141,14 @@ int udp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
if (restore) { if (restore) {
sk->sk_write_space = psock->saved_write_space; sk->sk_write_space = psock->saved_write_space;
WRITE_ONCE(sk->sk_prot, psock->sk_proto); sock_replace_proto(sk, psock->sk_proto);
return 0; return 0;
} }
if (sk->sk_family == AF_INET6) if (sk->sk_family == AF_INET6)
udp_bpf_check_v6_needs_rebuild(psock->sk_proto); udp_bpf_check_v6_needs_rebuild(psock->sk_proto);
WRITE_ONCE(sk->sk_prot, &udp_bpf_prots[family]); sock_replace_proto(sk, &udp_bpf_prots[family]);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(udp_bpf_update_proto); EXPORT_SYMBOL_GPL(udp_bpf_update_proto);

View File

@ -145,12 +145,12 @@ int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool re
if (restore) { if (restore) {
sk->sk_write_space = psock->saved_write_space; sk->sk_write_space = psock->saved_write_space;
WRITE_ONCE(sk->sk_prot, psock->sk_proto); sock_replace_proto(sk, psock->sk_proto);
return 0; return 0;
} }
unix_dgram_bpf_check_needs_rebuild(psock->sk_proto); unix_dgram_bpf_check_needs_rebuild(psock->sk_proto);
WRITE_ONCE(sk->sk_prot, &unix_dgram_bpf_prot); sock_replace_proto(sk, &unix_dgram_bpf_prot);
return 0; return 0;
} }
@ -158,12 +158,12 @@ int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool r
{ {
if (restore) { if (restore) {
sk->sk_write_space = psock->saved_write_space; sk->sk_write_space = psock->saved_write_space;
WRITE_ONCE(sk->sk_prot, psock->sk_proto); sock_replace_proto(sk, psock->sk_proto);
return 0; return 0;
} }
unix_stream_bpf_check_needs_rebuild(psock->sk_proto); unix_stream_bpf_check_needs_rebuild(psock->sk_proto);
WRITE_ONCE(sk->sk_prot, &unix_stream_bpf_prot); sock_replace_proto(sk, &unix_stream_bpf_prot);
return 0; return 0;
} }