]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: sockmap remove duplicate queue free
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 13 May 2019 14:19:37 +0000 (07:19 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jun 2019 06:00:06 +0000 (08:00 +0200)
commit3f53d093e5f9227a58776061803b769a761fd8b8
treec25a0a1d626118a1e2d92b8bd6076b488253f537
parent298d3dfbc0be2aa4ad901e73a49e60474b4c3d42
bpf: sockmap remove duplicate queue free

[ Upstream commit c42253cc88206fd0e9868c8b2fd7f9e79f9e0e03 ]

In tcp bpf remove we free the cork list and purge the ingress msg
list. However we do this before the ref count reaches zero so it
could be possible some other access is in progress. In this case
(tcp close and/or tcp_unhash) we happen to also hold the sock
lock so no path exists but lets fix it otherwise it is extremely
fragile and breaks the reference counting rules. Also we already
check the cork list and ingress msg queue and free them once the
ref count reaches zero so its wasteful to check twice.

Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/tcp_bpf.c