From: Martin KaFai Lau Date: Tue, 11 Jun 2019 21:45:57 +0000 (-0700) Subject: bpf: net: Set sk_bpf_storage back to NULL for cloned sk X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f12dd75959b0138f94da8ddcf43f2f3cf277216d;p=linux.git bpf: net: Set sk_bpf_storage back to NULL for cloned sk The cloned sk should not carry its parent-listener's sk_bpf_storage. This patch fixes it by setting it back to NULL. Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage") Signed-off-by: Martin KaFai Lau Acked-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann --- diff --git a/net/core/sock.c b/net/core/sock.c index 2b37019584862..d90fd04622e58 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1850,6 +1850,9 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) goto out; } RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL); +#ifdef CONFIG_BPF_SYSCALL + RCU_INIT_POINTER(newsk->sk_bpf_storage, NULL); +#endif newsk->sk_err = 0; newsk->sk_err_soft = 0;