1 From foo@baz Sat Apr 20 16:43:55 CEST 2019
2 From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
3 Date: Tue, 9 Apr 2019 11:47:20 +0200
4 Subject: net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv
6 From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
8 [ Upstream commit 988dc4a9a3b66be75b30405a5494faf0dc7cffb6 ]
10 gue tunnels run iptunnel_pull_offloads on received skbs. This can
11 determine a possible use-after-free accessing guehdr pointer since
12 the packet will be 'uncloned' running pskb_expand_head if it is a
13 cloned gso skb (e.g if the packet has been sent though a veth device)
15 Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap")
16 Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
17 Signed-off-by: David S. Miller <davem@davemloft.net>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 net/ipv4/fou.c | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
25 @@ -120,6 +120,7 @@ static int gue_udp_recv(struct sock *sk,
26 struct guehdr *guehdr;
33 @@ -211,13 +212,14 @@ static int gue_udp_recv(struct sock *sk,
34 if (unlikely(guehdr->control))
35 return gue_control_message(skb, guehdr);
37 + proto_ctype = guehdr->proto_ctype;
38 __skb_pull(skb, sizeof(struct udphdr) + hdrlen);
39 skb_reset_transport_header(skb);
41 if (iptunnel_pull_offloads(skb))
44 - return -guehdr->proto_ctype;
45 + return -proto_ctype;