Skip to contentSkip to conversation

net: ip6_gre: access skb data after skb_cow_head()

PATCH Superseded William Tu 2 participants 2 messages May 16, 2019 – May 18, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

William Tu

author
#0 lore raw

PATCH 1/1 net: ip6_gre: access skb data after skb_cow_head()

When increases the headroom, skb's pointer might get re-allocated. Fix it by moving skb_cow_head before accessing the skb->data pointer.

Fixes 01b8d064d58b4 ("net: ip6_gre: Request headroom in __gre6_xmit()")
---
 net/ipv6/ip6_gre.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/ip6_gre.c +3 -3
index 655e46b227f9..90b2b129b105 100644
@@ -714,6 +714,9 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
 	struct ip6_tnl *tunnel = netdev_priv(dev);
 	__be16 protocol;
 
+	if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen))
+		return -ENOMEM;
+
 	if (dev->type == ARPHRD_ETHER)
 		IPCB(skb)->flags = 0;
 
@@ -722,9 +725,6 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
 	else
 		fl6->daddr = tunnel->parms.raddr;
 
-	if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen))
-		return -ENOMEM;
-
 	/* Push GRE header. */
 	protocol = (dev->type == ARPHRD_ETHER) ? htons(ETH_P_TEB) : proto;
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

From: William Tu <[email protected]>
Date: Thu, 16 May 2019 09:25:48 -0700

Quoted 6 lines

When increases the headroom, skb's pointer might get re-allocated. Fix it by moving skb_cow_head before accessing the skb->data pointer.

Fixes 01b8d064d58b4 ("net: ip6_gre: Request headroom in __gre6_xmit()")

I don't understand the problem.

The fl6->daddr assignments are object copies, not pointer assignments.

So there are no dangling pointer references I can see.

Also, you need to explain exactly what dangling pointer is the problem in your commit message.