]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: remove SOCK_SUPPORT_ZC from sockmap
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 26 Oct 2022 23:25:57 +0000 (00:25 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 29 Oct 2022 03:21:25 +0000 (20:21 -0700)
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: cd55d475823c5 ("net: flag sockets supporting msghdr originated zerocopy")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/sock.h
net/ipv4/tcp_bpf.c
net/ipv4/udp_bpf.c
net/unix/unix_bpf.c

index 22f8bab583ddd8bb53bf88cf93c2e6a8b174d1dc..5db02546941cf8d532153ee23ef2164a2151ef98 100644 (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 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 {
        u64 transmit_time;
        u32 mark;
index a1626afe87a10d3506c96531a85a9ccb6ce3f8df..c501c329b1dbe4ba6383287bc74370c44e6cc42f 100644 (file)
@@ -607,7 +607,7 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
                } else {
                        sk->sk_write_space = psock->saved_write_space;
                        /* 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;
        }
@@ -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() */
-       WRITE_ONCE(sk->sk_prot, &tcp_bpf_prots[family][config]);
+       sock_replace_proto(sk, &tcp_bpf_prots[family][config]);
        return 0;
 }
 EXPORT_SYMBOL_GPL(tcp_bpf_update_proto);
index ff15918b7bdc7fac21a1b8eb51a5342349cff31a..e5dc91d0e0793ce6b203e0a6e4e0ffbd617b6820 100644 (file)
@@ -141,14 +141,14 @@ int udp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)
 
        if (restore) {
                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;
        }
 
        if (sk->sk_family == AF_INET6)
                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;
 }
 EXPORT_SYMBOL_GPL(udp_bpf_update_proto);
index 7cf14c6b172549a09f23e5eb41c145d0fb0cb931..e9bf155139612d84b0f52de487210ff916ea9b22 100644 (file)
@@ -145,12 +145,12 @@ int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool re
 
        if (restore) {
                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;
        }
 
        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;
 }
 
@@ -158,12 +158,12 @@ int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool r
 {
        if (restore) {
                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;
        }
 
        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;
 }