ipv4: fix a potential use after free
Subsystems (3)
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]>
Signed-off-by Li RongQing <[email protected]>
--- net/ipv4/ip_tunnel_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/ip_tunnel_core.c +2 -1
@@ -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
Quoted 8 lines · On Fri, Oct 17, 2014 at 1:53 AM, <[email protected]> wrote:
From: Li RongQing <[email protected]>
pskb_may_pull()maybe changeskb->dataand make eth pointer oboslete, so set eth afterpskb_may_pull()Fixes 3d7b46cd("ip_tunnel: push generic protocol handling to ip_tunnel module")Cc Pravin B Shelar <[email protected]>Signed-off-by Li RongQing <[email protected]>
Looks good.
Acked-by Pravin B Shelar <[email protected]>
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@@ -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
David Miller
maintainerFrom: [email protected]
Date: Fri, 17 Oct 2014 16:53:23 +0800
Quoted 8 lines
From: Li RongQing <[email protected]>
pskb_may_pull()maybe changeskb->dataand make eth pointer oboslete, so set eth afterpskb_may_pull()Fixes 3d7b46cd("ip_tunnel: push generic protocol handling to ip_tunnel module")Cc Pravin B Shelar <[email protected]>Signed-off-by Li RongQing <[email protected]>
Applied and queued up for -stable.