From: Lorenzo Bianconi Date: Tue, 9 Apr 2019 09:47:20 +0000 (+0200) Subject: net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv X-Git-Tag: v4.9.171~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d55ff2f0b34ce8b8cb165bc68e054f51b2740ee5;p=thirdparty%2Fkernel%2Fstable.git net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv [ Upstream commit 988dc4a9a3b66be75b30405a5494faf0dc7cffb6 ] gue tunnels run iptunnel_pull_offloads on received skbs. This can determine a possible use-after-free accessing guehdr pointer 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) Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap") Signed-off-by: Lorenzo Bianconi Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c index 030d1531e897a..17acc89f9dec8 100644 --- a/net/ipv4/fou.c +++ b/net/ipv4/fou.c @@ -119,6 +119,7 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) struct guehdr *guehdr; void *data; u16 doffset = 0; + u8 proto_ctype; if (!fou) return 1; @@ -210,13 +211,14 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) if (unlikely(guehdr->control)) return gue_control_message(skb, guehdr); + proto_ctype = guehdr->proto_ctype; __skb_pull(skb, sizeof(struct udphdr) + hdrlen); skb_reset_transport_header(skb); if (iptunnel_pull_offloads(skb)) goto drop; - return -guehdr->proto_ctype; + return -proto_ctype; drop: kfree_skb(skb);