bpf: sockmap only allow ESTABLISHED sock state
authorJohn Fastabend <john.fastabend@gmail.com>
Tue, 18 Sep 2018 16:01:44 +0000 (09:01 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 22 Sep 2018 00:46:41 +0000 (02:46 +0200)
commit5607fff303636d48b88414c6be353d9fed700af2
treebe7338b7007ecd330061ccbe9b00e339575c6f60
parent080220b687147fd9376878534aba7194f17f6ef5
bpf: sockmap only allow ESTABLISHED sock state

After this patch we only allow socks that are in ESTABLISHED state or
are being added via a sock_ops event that is transitioning into an
ESTABLISHED state. By allowing sock_ops events we allow users to
manage sockmaps directly from sock ops programs. The two supported
sock_ops ops are BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB and
BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB.

Similar to TLS ULP this ensures sk_user_data is correct.

Reported-by: Eric Dumazet <edumazet@google.com>
Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/sockmap.c