]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 24 Aug 2018 20:08:51 +0000 (22:08 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 28 Aug 2018 03:22:05 +0000 (20:22 -0700)
commit25d088af752fb5c2e0aaed070bf5beea182785c3
tree2f1a088152b28f8eb27233cf2aa2bc6a209f4974
parent2bcb71be637ba456d586452aa30c3c580469e4af
bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg

In bpf_tcp_recvmsg() we first took a reference on the psock, however
once we find that there are skbs in the normal socket's receive queue
we return with processing them through tcp_recvmsg(). Problem is that
we leak the taken reference on the psock in that path. Given we don't
really do anything with the psock at this point, move the skb_queue_empty()
test before we fetch the psock to fix this case.

Fixes: 685b9c18b8d6 ("bpf: sockmap redirect ingress support")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/sockmap.c