Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1659837 > unrolled thread

[PATCH 1/2] ip_tunnel: fix potential issue in ip_tunnel_rcv

Started byHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
First post2017-06-07 16:20 +0200
Last post2017-06-08 02:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] ip_tunnel: fix potential issue in ip_tunnel_rcv Haishuang Yan <yanhaishuang@cmss.chinamobile.com> - 2017-06-07 16:20 +0200
    [PATCH 2/2] ip6_tunnel: fix potential issue in __ip6_tnl_rcv Haishuang Yan <yanhaishuang@cmss.chinamobile.com> - 2017-06-07 16:20 +0200
    Re: [PATCH 1/2] ip_tunnel: fix potential issue in ip_tunnel_rcv Eric Dumazet <eric.dumazet@gmail.com> - 2017-06-07 17:00 +0200
      Re: [PATCH 1/2] ip_tunnel: fix potential issue in ip_tunnel_rcv 严海双 <yanhaishuang@cmss.chinamobile.com> - 2017-06-08 02:20 +0200

#1659837 — [PATCH 1/2] ip_tunnel: fix potential issue in ip_tunnel_rcv

FromHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date2017-06-07 16:20 +0200
Subject[PATCH 1/2] ip_tunnel: fix potential issue in ip_tunnel_rcv
Message-ID<tPJYt-7IG-3@gated-at.bofh.it>
When ip_tunnel_rcv fails, the tun_dst won't be freed, so move
skb_dst_set to begin and tun_dst would be freed by kfree_skb.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv4/ip_tunnel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index b878ecb..27fc20f 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -386,6 +386,9 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 	const struct iphdr *iph = ip_hdr(skb);
 	int err;
 
+	if (tun_dst)
+		skb_dst_set(skb, (struct dst_entry *)tun_dst);
+
 #ifdef CONFIG_NET_IPGRE_BROADCAST
 	if (ipv4_is_multicast(iph->daddr)) {
 		tunnel->dev->stats.multicast++;
@@ -439,9 +442,6 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 		skb->dev = tunnel->dev;
 	}
 
-	if (tun_dst)
-		skb_dst_set(skb, (struct dst_entry *)tun_dst);
-
 	gro_cells_receive(&tunnel->gro_cells, skb);
 	return 0;
 
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1659840 — [PATCH 2/2] ip6_tunnel: fix potential issue in __ip6_tnl_rcv

FromHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date2017-06-07 16:20 +0200
Subject[PATCH 2/2] ip6_tunnel: fix potential issue in __ip6_tnl_rcv
Message-ID<tPJYt-7IG-11@gated-at.bofh.it>
In reply to#1659837
When __ip6_tnl_rcv fails, the tun_dst won't be freed, so move
skb_dst_set to begin and tun_dst would be freed by kfree_skb.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv6/ip6_tunnel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 9b37f97..bf45f1b 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -789,6 +789,9 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 	const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
 	int err;
 
+	if (tun_dst)
+		skb_dst_set(skb, (struct dst_entry *)tun_dst);
+
 	if ((!(tpi->flags & TUNNEL_CSUM) &&
 	     (tunnel->parms.i_flags & TUNNEL_CSUM)) ||
 	    ((tpi->flags & TUNNEL_CSUM) &&
@@ -852,9 +855,6 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 
 	skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(tunnel->dev)));
 
-	if (tun_dst)
-		skb_dst_set(skb, (struct dst_entry *)tun_dst);
-
 	gro_cells_receive(&tunnel->gro_cells, skb);
 	return 0;
 
-- 
1.8.3.1

[toc] | [prev] | [next] | [standalone]


#1659877

FromEric Dumazet <eric.dumazet@gmail.com>
Date2017-06-07 17:00 +0200
Message-ID<tPKBc-7Z0-17@gated-at.bofh.it>
In reply to#1659837
On Wed, 2017-06-07 at 22:16 +0800, Haishuang Yan wrote:
> When ip_tunnel_rcv fails, the tun_dst won't be freed, so move
> skb_dst_set to begin and tun_dst would be freed by kfree_skb.
> 
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> ---

Please add the missing Fixes: tag and CC author of the patch that added
this bug, so that he has a chance to comment and avoid future similar
bugs.

Thanks.

[toc] | [prev] | [next] | [standalone]


#1660596

From严海双 <yanhaishuang@cmss.chinamobile.com>
Date2017-06-08 02:20 +0200
Message-ID<tPTl8-5lN-23@gated-at.bofh.it>
In reply to#1659877
> On 7 Jun 2017, at 10:48 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 
> On Wed, 2017-06-07 at 22:16 +0800, Haishuang Yan wrote:
>> When ip_tunnel_rcv fails, the tun_dst won't be freed, so move
>> skb_dst_set to begin and tun_dst would be freed by kfree_skb.
>> 
>> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
>> ---
> 
> Please add the missing Fixes: tag and CC author of the patch that added
> this bug, so that he has a chance to comment and avoid future similar
> bugs.
> 
> Thanks.
> 
> 
> 

Ok, I will add these information in v2 commit.
Thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web