bpf: Don't refcount LISTEN sockets in sk_assign()

[ upstream commit 7ae215d23c12a939005f35d1848ca55b6109b9c0 ]

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
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Change-Id: Ifdd4581c618d137c6895833cbc11d923dd573a88
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/8211
Reviewed-by: Roy Yang <royyang@google.com>
Tested-by: Roy Yang <royyang@google.com>
3 files changed