From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, ebiederm@xmission.com,
daniel@iogearbox.net
Subject: Re: [PATCH nf RFC] netfilter: fix netns dependencies with conntrack templates
Date: Mon, 13 Jul 2015 21:26:55 +0200 [thread overview]
Message-ID: <20150713192655.GA25674@breakpoint.cc> (raw)
In-Reply-To: <1436793108-3807-1-git-send-email-pablo@netfilter.org>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> +static struct nf_conn *get_next_tmpl(struct net *net)
> +{
> + struct nf_conntrack_tuple_hash *h;
> + struct hlist_nulls_node *n;
> + struct nf_conn *ct = NULL;
> + int cpu;
> +
> + for_each_possible_cpu(cpu) {
> + struct ct_pcpu *pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu);
> +
> + spin_lock_bh(&pcpu->lock);
> + hlist_nulls_for_each_entry(h, n, &pcpu->tmpl, hnnode) {
> + ct = nf_ct_tuplehash_to_ctrack(h);
> + break;
> + }
> + spin_unlock_bh(&pcpu->lock);
> + }
> + return ct;
> +}
> +
> +void nf_ct_tmpl_cleanup(struct net *net)
> +{
> + struct nf_conn *tmpl;
> +
> +i_see_dead_people:
> + while ((tmpl = get_next_tmpl(net)) != NULL)
> + nf_ct_put(tmpl);
> +
This seems bogus, this _puts() conntracks we don't own, leading
to refcnt underflow/use-after-free?
I'd just get rid of all of the above. After your change we
don't depend on the kmem_cache anymore so its ok to leave freeing to
the CT target ->destroy() hook, provided we also fix up the tmpl list
handling (i'd suggest to just remove it and make each template sit
on their 'own' list -- so the hlist_nulls_unhashed() BUG_ONs don't
fire).
Other than that, this patch seems like the least ugly approach.
Thanks Pablo!
prev parent reply other threads:[~2015-07-13 19:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-13 13:11 [PATCH nf RFC] netfilter: fix netns dependencies with conntrack templates Pablo Neira Ayuso
2015-07-13 16:00 ` Daniel Borkmann
2015-07-13 19:26 ` Florian Westphal [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=20150713192655.GA25674@breakpoint.cc \
--to=fw@strlen.de \
--cc=daniel@iogearbox.net \
--cc=ebiederm@xmission.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/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).