Patchwork netfilter: Don't leak 'exp' in ctnetlink_create_expect()

login
register
mail settings
Submitter Jesper Juhl
Date Dec. 26, 2012, 9:49 p.m.
Message ID <alpine.LNX.2.00.1212262246390.23814@swampdragon.chaosbits.net>
Download mbox | patch
Permalink /patch/208218/
State Accepted
Headers show

Comments

Jesper Juhl - Dec. 26, 2012, 9:49 p.m.
'if ((!help) && (!cda[CTA_EXPECT_TIMEOUT]))' then we should remember
to free 'exp' that was allocated by 'nf_ct_expect_alloc()' by jumping
to the 'err_out' label rather than the 'out' label in
ctnetlink_create_expect().
This patch should get rid of the leak.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/netfilter/nf_conntrack_netlink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

 note: compile tested only.
Pablo Neira - Dec. 26, 2012, 10:09 p.m.
On Wed, Dec 26, 2012 at 10:49:40PM +0100, Jesper Juhl wrote:
> 'if ((!help) && (!cda[CTA_EXPECT_TIMEOUT]))' then we should remember
> to free 'exp' that was allocated by 'nf_ct_expect_alloc()' by jumping
> to the 'err_out' label rather than the 'out' label in
> ctnetlink_create_expect().
> This patch should get rid of the leak.

Applied, thanks Jesper.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 4e078cd..627b0e5 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -2624,7 +2624,7 @@  ctnetlink_create_expect(struct net *net, u16 zone,
 	if (!help) {
 		if (!cda[CTA_EXPECT_TIMEOUT]) {
 			err = -EINVAL;
-			goto out;
+			goto err_out;
 		}
 		exp->timeout.expires =
 		  jiffies + ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ;