]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: sockmap, fix crash when ipv6 sock is added
authorJohn Fastabend <john.fastabend@gmail.com>
Sat, 30 Jun 2018 13:17:36 +0000 (06:17 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 30 Jun 2018 23:21:31 +0000 (01:21 +0200)
commita7e2c3f777437530c63287ea3a75b5b540ab7598
tree73ee61f04a80beb5ac6002d0c33ab30127ade630
parent69b4d638af0070de1b4ac573e3eda7d309dc39f1
bpf: sockmap, fix crash when ipv6 sock is added

This fixes a crash where we assign tcp_prot to IPv6 sockets instead
of tcpv6_prot.

Previously we overwrote the sk->prot field with tcp_prot even in the
AF_INET6 case. This patch ensures the correct tcp_prot and tcpv6_prot
are used.

Tested with 'netserver -6' and 'netperf -H [IPv6]' as well as
'netperf -H [IPv4]'. The ESTABLISHED check resolves the previously
crashing case here.

Fixes: 26ac83c2c880 ("bpf: sockmap with sk redirect support")
Reported-by: syzbot+5c063698bdbfac19f363@syzkaller.appspotmail.com
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/sockmap.c