]> www.infradead.org Git - users/dwmw2/linux.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Oct 2018 06:55:51 +0000 (08:55 +0200)
commit7feb1f2b5d8d2b878adb7afcc23b6cb3df0eebbe
tree1a8256bbe4a0a63225eafc98089a5784846f8f71
parent427e7707d9325a2cbf308221cc24e2761fa7245d
bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg

[ Upstream commit 15c480efab01197c965ce0562a43ffedd852b8f9 ]

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: 8934ce2fd081 ("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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/sockmap.c