Skip to contentSkip to conversation

ipv4: fix a potential use after free

PATCH In review [email protected] 3 participants 3 messages Oct 17, 2014 – Oct 18, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: fix a potential use after free

From: Li RongQing <[email protected]>

pskb_may_pull() maybe change skb->data and make eth pointer oboslete, so set eth after pskb_may_pull()

Fixes 3d7b46cd("ip_tunnel: push generic protocol handling to ip_tunnel module")
Cc Pravin B Shelar <[email protected]>
---
 net/ipv4/ip_tunnel_core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel_core.c +2 -1
index f4c987b..88c386c 100644
@@ -91,11 +91,12 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
 	skb_pull_rcsum(skb, hdr_len);
 
 	if (inner_proto == htons(ETH_P_TEB)) {
-		struct ethhdr *eh = (struct ethhdr *)skb->data;
+		struct ethhdr *eh;
 
 		if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
 			return -ENOMEM;
 
+		eh = (struct ethhdr *)skb->data;
 		if (likely(ntohs(eh->h_proto) >= ETH_P_802_3_MIN))
 			skb->protocol = eh->h_proto;
 		else
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Fri, Oct 17, 2014 at 1:53 AM, <[email protected]> wrote:

From: Li RongQing <[email protected]>

pskb_may_pull() maybe change skb->data and make eth pointer oboslete, so set eth after pskb_may_pull()

Fixes 3d7b46cd("ip_tunnel: push generic protocol handling to ip_tunnel module")
Cc Pravin B Shelar <[email protected]>

Looks good.

Quoted 25 lines
---
 net/ipv4/ip_tunnel_core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel_core.c +2 -2
index f4c987b..88c386c 100644
@@ -91,11 +91,12 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
        skb_pull_rcsum(skb, hdr_len);
 
        if (inner_proto == htons(ETH_P_TEB)) {
-               struct ethhdr *eh = (struct ethhdr *)skb->data;
+               struct ethhdr *eh;
 
                if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
                        return -ENOMEM;
 
+               eh = (struct ethhdr *)skb->data;
                if (likely(ntohs(eh->h_proto) >= ETH_P_802_3_MIN))
                        skb->protocol = eh->h_proto;
                else
--

1.7.10.4

maintainer
#2 lore raw
In reply to [email protected]

From: [email protected]
Date: Fri, 17 Oct 2014 16:53:23 +0800

Quoted 8 lines

From: Li RongQing <[email protected]>

pskb_may_pull() maybe change skb->data and make eth pointer oboslete, so set eth after pskb_may_pull()

Fixes 3d7b46cd("ip_tunnel: push generic protocol handling to ip_tunnel module")
Cc Pravin B Shelar <[email protected]>

Applied and queued up for -stable.