net: ip6_gre: fix possible use-after-free in ip6erspan_rcv
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Sat, 6 Apr 2019 15:16:53 +0000 (17:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2019 06:38:43 +0000 (08:38 +0200)
commita2ef7723a13c6d6909371a5a4b640a266ae07b8b
tree26077ef25987276cf7043304adf74182756d7421
parent5c6f2f4c0e9f91daa436d118a7f5c2142541e4ac
net: ip6_gre: fix possible use-after-free in ip6erspan_rcv

[ Upstream commit 2a3cabae4536edbcb21d344e7aa8be7a584d2afb ]

erspan_v6 tunnels run __iptunnel_pull_header on received skbs to remove
erspan header. This can determine a possible use-after-free accessing
pkt_md pointer in ip6erspan_rcv since the packet will be 'uncloned'
running pskb_expand_head if it is a cloned gso skb (e.g if the packet has
been sent though a veth device). Fix it resetting pkt_md pointer after
__iptunnel_pull_header

Fixes: 1d7e2ed22f8d ("net: erspan: refactor existing erspan code")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv6/ip6_gre.c