summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2019-05-13 10:19:37 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2019-05-13 19:31:43 -0400
commitc42253cc88206fd0e9868c8b2fd7f9e79f9e0e03 (patch)
tree60ad037d2145902c7a9632863f04d6bd6248c372
parent014894360ec95abe868e94416b3dd6569f6e2c0c (diff)
bpf: sockmap remove duplicate queue free
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>
-rw-r--r--net/ipv4/tcp_bpf.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 1bb7321a256d..4a619c85daed 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -528,8 +528,6 @@ static void tcp_bpf_remove(struct sock *sk, struct sk_psock *psock)
528{ 528{
529 struct sk_psock_link *link; 529 struct sk_psock_link *link;
530 530
531 sk_psock_cork_free(psock);
532 __sk_psock_purge_ingress_msg(psock);
533 while ((link = sk_psock_link_pop(psock))) { 531 while ((link = sk_psock_link_pop(psock))) {
534 sk_psock_unlink(sk, link); 532 sk_psock_unlink(sk, link);
535 sk_psock_free_link(link); 533 sk_psock_free_link(link);