All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv
@ 2017-12-14 15:15 Haishuang Yan
  2017-12-14 15:15 ` [PATCH 2/2] ip6_gre: fix potential memory leak in ip6erspan_rcv Haishuang Yan
  2017-12-14 18:47 ` [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv William Tu
  0 siblings, 2 replies; 4+ messages in thread
From: Haishuang Yan @ 2017-12-14 15:15 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: netdev, linux-kernel, Haishuang Yan, William Tu

If md is NULL, tun_dst must be freed, otherwise it will cause memory
leak.

Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv4/ip_gre.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index d828821..9253d6f 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -304,8 +304,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 				return PACKET_REJECT;
 
 			md = ip_tunnel_info_opts(&tun_dst->u.tun_info);
-			if (!md)
+			if (!md) {
+				dst_release((struct dst_entry *)tun_dst);
 				return PACKET_REJECT;
+			}
 
 			md->index = index;
 			info = &tun_dst->u.tun_info;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ip6_gre: fix potential memory leak in ip6erspan_rcv
  2017-12-14 15:15 [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv Haishuang Yan
@ 2017-12-14 15:15 ` Haishuang Yan
  2017-12-14 18:47 ` [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv William Tu
  1 sibling, 0 replies; 4+ messages in thread
From: Haishuang Yan @ 2017-12-14 15:15 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: netdev, linux-kernel, Haishuang Yan, William Tu

If md is NULL, tun_dst must be freed, otherwise it will cause memory
leak

Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv6/ip6_gre.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 4562579..b8b0e4b 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -542,8 +542,10 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len,
 
 			info = &tun_dst->u.tun_info;
 			md = ip_tunnel_info_opts(info);
-			if (!md)
+			if (!md) {
+				dst_release((struct dst_entry *)tun_dst);
 				return PACKET_REJECT;
+			}
 
 			md->index = index;
 			info->key.tun_flags |= TUNNEL_ERSPAN_OPT;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv
  2017-12-14 15:15 [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv Haishuang Yan
  2017-12-14 15:15 ` [PATCH 2/2] ip6_gre: fix potential memory leak in ip6erspan_rcv Haishuang Yan
@ 2017-12-14 18:47 ` William Tu
  2017-12-15  1:16   ` 严海双
  1 sibling, 1 reply; 4+ messages in thread
From: William Tu @ 2017-12-14 18:47 UTC (permalink / raw)
  To: Haishuang Yan
  Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	linux-kernel, Linux Kernel Network Developers

On Thu, Dec 14, 2017 at 7:15 AM, Haishuang Yan
<yanhaishuang@cmss.chinamobile.com> wrote:
> If md is NULL, tun_dst must be freed, otherwise it will cause memory
> leak.
>
> Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
> Cc: William Tu <u9012063@gmail.com>
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> ---
>  net/ipv4/ip_gre.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index d828821..9253d6f 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -304,8 +304,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
>                                 return PACKET_REJECT;
>
>                         md = ip_tunnel_info_opts(&tun_dst->u.tun_info);
> -                       if (!md)
> +                       if (!md) {
> +                               dst_release((struct dst_entry *)tun_dst);
>                                 return PACKET_REJECT;
> +                       }
I'm not sure about this. Maybe we don't even need to check "if (!md)"
since ip_tun_rx_dst does the memory allocation.
William

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv
  2017-12-14 18:47 ` [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv William Tu
@ 2017-12-15  1:16   ` 严海双
  0 siblings, 0 replies; 4+ messages in thread
From: 严海双 @ 2017-12-15  1:16 UTC (permalink / raw)
  To: William Tu
  Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	linux-kernel, Linux Kernel Network Developers



> On 2017年12月15日, at 上午2:47, William Tu <u9012063@gmail.com> wrote:
> 
> On Thu, Dec 14, 2017 at 7:15 AM, Haishuang Yan
> <yanhaishuang@cmss.chinamobile.com> wrote:
>> If md is NULL, tun_dst must be freed, otherwise it will cause memory
>> leak.
>> 
>> Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
>> Cc: William Tu <u9012063@gmail.com>
>> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
>> ---
>> net/ipv4/ip_gre.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
>> index d828821..9253d6f 100644
>> --- a/net/ipv4/ip_gre.c
>> +++ b/net/ipv4/ip_gre.c
>> @@ -304,8 +304,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
>>                                return PACKET_REJECT;
>> 
>>                        md = ip_tunnel_info_opts(&tun_dst->u.tun_info);
>> -                       if (!md)
>> +                       if (!md) {
>> +                               dst_release((struct dst_entry *)tun_dst);
>>                                return PACKET_REJECT;
>> +                       }
> I'm not sure about this. Maybe we don't even need to check "if (!md)"
> since ip_tun_rx_dst does the memory allocation.
> William
> 


Hi, William

I think we need to check “if (!md)”, if md is okay, ip_tunnel_rcv will be responsible to free
tun_dst:

 448 drop:
 449     if (tun_dst)
 450         dst_release((struct dst_entry *)tun_dst);

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-15  1:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 15:15 [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv Haishuang Yan
2017-12-14 15:15 ` [PATCH 2/2] ip6_gre: fix potential memory leak in ip6erspan_rcv Haishuang Yan
2017-12-14 18:47 ` [PATCH 1/2] ip_gre: fix potential memory leak in erspan_rcv William Tu
2017-12-15  1:16   ` 严海双

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.