All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Gao feng <gaofeng@cn.fujitsu.com>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2 -next] netfilter: ctnetlink: attach expectations to unconfirmed conntracks
Date: Wed, 7 Aug 2013 12:46:53 +0200	[thread overview]
Message-ID: <20130807104653.GA29345@breakpoint.cc> (raw)
In-Reply-To: <20130807104034.GA7500@localhost>

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Wed, Aug 07, 2013 at 06:27:19PM +0800, Gao feng wrote:
> > On 08/06/2013 09:19 PM, Pablo Neira Ayuso wrote:
> > > This patch adds the capability to attach expectations to unconfirmed
> > > conntrack entries. This patch is required by conntrack helpers that
> > > trigger expectations based on the first packet seen like the TFTP and
> > > the DHCPv6 user-space helpers.
> > > 
> > > There is no need to bump the conntrack refcount since unconfirmed
> > > conntracks are not yet in the hashes, thus, they are just referenced
> > > by one single packet. There is no trouble either in the get_next_corpse
> > > path, as unconfirmed conntracks only get their dying bit set to
> > > be discarded later on by nf_conntrack_confirm.
> > > 
> > 
> > The use after free problem still may happen.
> > 
> > the unconfirmed conntrack is created when we receive the first packet,
> > then this conntrack is linked in the per net global unconfirmed list.
> > 
> > And this conntrack may be destroyed when the return value of l4proto->packet
> > low than 0 in nf_conntrack_in.
> 
> I'm calling this from nfqueue, so the packet is retained until the
> user-space application issues the verdict on it, in that case that's
> not possible.
> 
> But that interface is generic and to get this working in all cases, I
> need the bump the refcount. So you're right, I'm going to revamp this.

Sorry, but I don't see how this approach will work in practice.

The kernel will frequently rip out entries from the unconfirmed list
and put them in the hash table, so on busy machines you'll often end up NOT
finding the conntrack you're looking for, because ct entry was moved to
the hash table and you hit the nulls element of some table bucket...

  reply	other threads:[~2013-08-07 10:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 13:19 [PATCH v2 -next] netfilter: ctnetlink: attach expectations to unconfirmed conntracks Pablo Neira Ayuso
2013-08-07 10:27 ` Gao feng
2013-08-07 10:40   ` Pablo Neira Ayuso
2013-08-07 10:46     ` Florian Westphal [this message]
2013-08-07 11:27       ` Pablo Neira Ayuso

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=20130807104653.GA29345@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=gaofeng@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.