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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4E32C633.5000205@trash.net>
Date:	Fri, 29 Jul 2011 16:39:47 +0200
From:	Patrick McHardy <kaber@...sh.net>
To:	Jesper Juhl <jj@...osbits.net>
CC:	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	coreteam@...filter.org, netfilter@...r.kernel.org,
	netfilter-devel@...r.kernel.org,
	Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
	James Morris <jmorris@...ei.org>,
	"Pekka Savola (ipv6)" <pekkas@...core.fi>,
	Alexey Kuznetsov <kuznet@....inr.ac.ru>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH][RFC] netfilter: Fix small leak in ipq_build_packet_message()

On 17.07.2011 19:46, Jesper Juhl wrote:
> ipq_build_packet_message() in net/ipv4/netfilter/ip_queue.c and
> net/ipv6/netfilter/ip6_queue.c contain a small potential mem leak as
> far as I can tell.
> 
> We allocate memory for 'skb' with alloc_skb() annd then call
>  nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));
> 
> NLMSG_PUT is a macro
>  NLMSG_PUT(skb, pid, seq, type, len) \
>   		NLMSG_NEW(skb, pid, seq, type, len, 0)
> 
> that expands to NLMSG_NEW, which is also a macro which expands to:
>  NLMSG_NEW(skb, pid, seq, type, len, flags) \
>   	({	if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
>   			goto nlmsg_failure; \
>   		__nlmsg_put(skb, pid, seq, type, len, flags); })
> 
> If we take the true branch of the 'if' statement and 'goto
> nlmsg_failure', then we'll, at that point, return from
> ipq_build_packet_message() without having assigned 'skb' to anything
> and we'll leak the memory we allocated for it when it goes out of
> scope.
> 
> Fix this by placing a 'kfree(skb)' at 'nlmsg_failure'.
> 
> I admit that I do not know how likely this to actually happen or even
> if there's something that guarantees that it will never happen - I'm
> not that familiar with this code, but if that is so, I've not been
> able to spot it.
> 
> Please review and commit if you believe this is correct. Thanks.
> 

Looks correct, applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ