From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf,v2] netfilter: conntrack: add dead flag to helpers
Date: Fri, 15 May 2026 01:53:18 +0200 [thread overview]
Message-ID: <agZgbk_F3Clt1bQ5@chamomile> (raw)
In-Reply-To: <agZbFvp_KgGUr2Kw@chamomile>
On Fri, May 15, 2026 at 01:30:33AM +0200, Pablo Neira Ayuso wrote:
> On Thu, May 14, 2026 at 05:44:58PM +0200, Florian Westphal wrote:
> > Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > On Thu, May 14, 2026 at 04:43:17PM +0200, Florian Westphal wrote:
> > > > Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > > > Add a new NF_CT_HELPER_F_DEAD helper flag to notify the packet path that
> > > > > this helper is going away. Thus, helpers are effectively disabled and no
> > > > > new expectations are created while removing the expectations created by
> > > > > this helper as well as unhelping the existing conntrack entries.
> > > > >
> > > > > Add the check for NF_CT_HELPER_F_DEAD in the packet path to:
> > > > > - Conntrack confirmation path which invokes the helper callback.
> > > > > - Propagation of helper to conntrack via expectation.
> > > > > - OVS ct helper invocation.
> > > >
> > > > Not sure this is enough. New conntracks are not in any hash table /
> > > > unreachable, and synchronize_rcu() doesn't guarantee they get confirmed
> > > > (can get queued).
> > >
> > > nf_ct_iterate_destroy() calls nf_queue_nf_hook_drop() for each netns.
> >
> > But is that enough? Consider:
> >
> > cpu0 cpu1
> > recieves verdict
> > unlink from nfqueue list
> > drop_queued_packets (misses unlinked)
> > ... going on ..
>
> This looks like a general problem with nf_queue_nf_hook_drop().
>
> > I think to properly resolve this, there is a need to check
> > for this new dead flag after queueing to userspace (after its on list)
> > and again when receiving the verdict.
> >
> > Arguably this is kind of different bug, because this comment is wrong:
> >
> > /* a skb w. unconfirmed conntrack could have been reinjected just
> > * before we called nf_queue_nf_hook_drop().
> > *
> > * This makes sure its inserted into conntrack table.
> > */
> > synchronize_net();
> >
> > (it could have been requeued).
> >
> > I think a more generic fix is to add a seqcnt to nf_queue_entry.
> > When queueing, record current seqcnt.
> >
> > On reinject, drop if unconfirmed and seqcnt_now != entry->seqcnt.
> > Not nice, but I don't see a better way ATM.
>
> But you would need to check right before enqueueing (adding to the
> hashtable/list), so the race would still be there?
>
> > The seqcnt can be pernet and it can be restricted to nfnetlink_queue.
> >
> > Any better idea?
>
> Maybe add a helper_id which is set at helper registration time. Then
> nf_conn_help stores this helper_id field. Unconfirmed conntrack on
> reinject use this helper_id to re-lookup the helper when reinjecting.
> This would force a slow path for unconfirmed conntracks, to
> re-validate if the helper is still there.
>
> cttimeout would need this too, a lookup to check if the timeout policy
> is still around.
Hm.
struct nf_ct_ext {
u8 offset[NF_CT_EXT_NUM];
u8 len;
unsigned int gen_id; <---- There is already a gen_id here.
And nf_ct_ext_bump_genid() is called from nf_ct_iterate_destroy().
Maybe we could simply check if there is a mismatch in this generation
id from reinject path?
next prev parent reply other threads:[~2026-05-14 23:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 14:30 [PATCH nf,v2] netfilter: conntrack: add dead flag to helpers Pablo Neira Ayuso
2026-05-14 14:43 ` Florian Westphal
2026-05-14 15:10 ` Pablo Neira Ayuso
2026-05-14 15:44 ` Florian Westphal
2026-05-14 23:30 ` Pablo Neira Ayuso
2026-05-14 23:53 ` Pablo Neira Ayuso [this message]
2026-05-14 23:55 ` Florian Westphal
2026-05-15 0:10 ` Pablo Neira Ayuso
2026-05-15 0:21 ` 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=agZgbk_F3Clt1bQ5@chamomile \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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.