]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: sockmap, fix transition through disconnect without close
authorJohn Fastabend <john.fastabend@gmail.com>
Tue, 18 Sep 2018 16:01:49 +0000 (09:01 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 22 Sep 2018 00:46:41 +0000 (02:46 +0200)
commit896d7b8b999bb8d0dc644fd1d7839635eb526858
tree15a5f8f63fcea18adbfeeaff94ae6869f3cecc74
parent94eb82f469a171a64e8654f46efe754a4da0692f
bpf: sockmap, fix transition through disconnect without close

It is possible (via shutdown()) for TCP socks to go trough TCP_CLOSE
state via tcp_disconnect() without actually calling tcp_close which
would then call our bpf_tcp_close() callback. Because of this a user
could disconnect a socket then put it in a LISTEN state which would
break our assumptions about sockets always being ESTABLISHED state.

To resolve this rely on the unhash hook, which is called in the
disconnect case, to remove the sock from the sockmap.

Reported-by: Eric Dumazet <edumazet@google.com>
Fixes: 91ac8c26a2a7 ("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