netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jeffy Chen <jeffy.chen@rock-chips.com>
Cc: Douglas Anderson <dianders@chromium.org>,
	Brian Norris <briannorris@chromium.org>,
	netfilter-devel@vger.kernel.org, zlpnobody@163.com
Subject: Re: [PATCH] [RESENT]netfilter: nfnetlink_cthelper: Fix memory leak
Date: Tue, 21 Mar 2017 12:59:38 +0100	[thread overview]
Message-ID: <20170321115938.GA7809@salvia> (raw)
In-Reply-To: <1490080030-6799-1-git-send-email-jeffy.chen@rock-chips.com>

On Tue, Mar 21, 2017 at 03:07:10PM +0800, Jeffy Chen wrote:
> We have memory leaks of nf_conntrack_helper & expect_policy.
> 
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
>  net/netfilter/nfnetlink_cthelper.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
> index de87823..99d4bd7 100644
> --- a/net/netfilter/nfnetlink_cthelper.c
> +++ b/net/netfilter/nfnetlink_cthelper.c
> @@ -191,6 +191,8 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper,
>  		if (ret < 0)
>  			goto err;
>  	}
> +
> +	kfree(helper->expect_policy);
>  	helper->expect_policy = expect_policy;

This is fixing the leak, however this is not safe since a packet may
be still walking on the older helper->expect_policy.

        old_expect_policy = helper->expect_policy);
        helper->expect_policy = expect_policy;
        kfree(old_expect_policy);

We need to protect this with RCU if we want to support expectation
policy updates properly.

I'm going to take this patch, but we have to follow up on this.

      parent reply	other threads:[~2017-03-21 11:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1490080030-6799-1-git-send-email-jeffy.chen@rock-chips.com>
2017-03-21 11:31 ` [PATCH] [RESENT]netfilter: nfnetlink_cthelper: Fix memory leak Pablo Neira Ayuso
2017-03-21 11:59 ` Pablo Neira Ayuso [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170321115938.GA7809@salvia \
    --to=pablo@netfilter.org \
    --cc=briannorris@chromium.org \
    --cc=dianders@chromium.org \
    --cc=jeffy.chen@rock-chips.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=zlpnobody@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).