Skip to contentSkip to conversation

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

PATCH In review Lorenzo Bianconi 2 participants 2 messages Apr 9, 2019 – Apr 11, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 net: fou: do not use guehdr after iptunnel_pull_offloads in gue_udp_recv

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")
---
 net/ipv4/fou.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/fou.c +3 -1
index 79e98e21cdd7..12ce6c526d72 100644
@@ -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;
@@ -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);
Signature · 1 line
2.20.1
maintainer
#2 lore raw

From: Lorenzo Bianconi <[email protected]>
Date: Tue, 9 Apr 2019 11:47:20 +0200

Quoted 7 lines

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")

Applied and queued up for -stable, thanks.