Skip to content

Commit

Permalink
net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv
Browse files Browse the repository at this point in the history
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: a09a4c8 ("tunnels: Remove encapsulation offloads on decap")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
LorenzoBianconi authored and davem330 committed Apr 11, 2019
1 parent d184153 commit 988dc4a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/ipv4/fou.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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;
Expand Down Expand Up @@ -212,13 +213,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);
Expand Down

0 comments on commit 988dc4a

Please sign in to comment.