Commit df764e34 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Stefan Bader

net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv

BugLink: https://bugs.launchpad.net/bugs/1828420

[ Upstream commit 988dc4a9 ]

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: a09a4c8d ("tunnels: Remove encapsulation offloads on decap")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent aff5a41f
...@@ -116,6 +116,7 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) ...@@ -116,6 +116,7 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
struct guehdr *guehdr; struct guehdr *guehdr;
void *data; void *data;
u16 doffset = 0; u16 doffset = 0;
u8 proto_ctype;
if (!fou) if (!fou)
return 1; return 1;
...@@ -173,13 +174,14 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) ...@@ -173,13 +174,14 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
if (unlikely(guehdr->control)) if (unlikely(guehdr->control))
return gue_control_message(skb, guehdr); return gue_control_message(skb, guehdr);
proto_ctype = guehdr->proto_ctype;
__skb_pull(skb, sizeof(struct udphdr) + hdrlen); __skb_pull(skb, sizeof(struct udphdr) + hdrlen);
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
if (iptunnel_pull_offloads(skb)) if (iptunnel_pull_offloads(skb))
goto drop; goto drop;
return -guehdr->proto_ctype; return -proto_ctype;
drop: drop:
kfree_skb(skb); kfree_skb(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment