lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Jun 2014 00:00:51 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	roy.qing.li@...il.com
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH] 8021q: fix a potential memory leak

On Wed, 2014-06-18 at 13:46 +0800, roy.qing.li@...il.com wrote:
> From: Li RongQing <roy.qing.li@...il.com>
> 
> skb_cow called in vlan_reorder_header does not free the skb when it failed,
> and vlan_reorder_header returns NULL to reset original skb when it is called
> in vlan_untag, lead to a memory leak.
> 
> Signed-off-by: Li RongQing <roy.qing.li@...il.com>
> ---
>  net/8021q/vlan_core.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
> index 9012b1c..75d4277 100644
> --- a/net/8021q/vlan_core.c
> +++ b/net/8021q/vlan_core.c
> @@ -114,8 +114,11 @@ EXPORT_SYMBOL(vlan_dev_vlan_proto);
>  
>  static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
>  {
> -	if (skb_cow(skb, skb_headroom(skb)) < 0)
> +	if (skb_cow(skb, skb_headroom(skb)) < 0) {
> +		kfree_skb(skb);
>  		return NULL;
> +	}
> +
>  	memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
>  	skb->mac_header += VLAN_HLEN;
>  	return skb;

Good catch.

Acked-by: Eric Dumazet <edumazet@...gle.com>

Note that the 'goto err_free;' in caller is misleading as well, as skb
is NULL.

vlan_reorder_header() could return an error code instead of a skb...



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ