bpf: Don't refcount LISTEN sockets in sk_assign()
Avoid taking a reference on listen sockets by checking the socket type in the sk_assign and in the corresponding skb_steal_sock() code in the the transport layer, and by ensuring that the prefetch free (sock_pfree) function uses the same logic to check whether the socket is refcounted. Suggested-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Joe Stringer <joe@wand.net.nz> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200329225342.16317-4-joe@wand.net.nz
This commit is contained in:
committed by
Alexei Starovoitov
parent
71489e21d7
commit
7ae215d23c
@@ -2077,7 +2077,8 @@ EXPORT_SYMBOL(sock_efree);
|
||||
#ifdef CONFIG_INET
|
||||
void sock_pfree(struct sk_buff *skb)
|
||||
{
|
||||
sock_gen_put(skb->sk);
|
||||
if (sk_is_refcounted(skb->sk))
|
||||
sock_gen_put(skb->sk);
|
||||
}
|
||||
EXPORT_SYMBOL(sock_pfree);
|
||||
#endif /* CONFIG_INET */
|
||||
|
||||
Reference in New Issue
Block a user