tcp: take care of truncations done by sk_filter()
authorEric Dumazet <edumazet@google.com>
Thu, 10 Nov 2016 21:12:35 +0000 (13:12 -0800)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Feb 2017 10:03:46 +0000 (11:03 +0100)
commit56325d9fb7b138b228577ae99382b70084ab82f3
tree3501ed6f8a4a985b631713661efc41ad043f2bad
parentd318f82f1c4e3823253fcc9dc2053a46ef7b14a6
tcp: take care of truncations done by sk_filter()

commit ac6e780070e30e4c35bd395acfe9191e6268bdd3 upstream.

With syzkaller help, Marco Grassi found a bug in TCP stack,
crashing in tcp_collapse()

Root cause is that sk_filter() can truncate the incoming skb,
but TCP stack was not really expecting this to happen.
It probably was expecting a simple DROP or ACCEPT behavior.

We first need to make sure no part of TCP header could be removed.
Then we need to adjust TCP_SKB_CB(skb)->end_seq

Many thanks to syzkaller team and Marco for giving us a reproducer.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Marco Grassi <marco.gra@gmail.com>
Reported-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/linux/filter.h
include/net/tcp.h
net/core/filter.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c