Linux Netfilter development
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: Pham Thanh Tuyen <phamtyn@gmail.com>,
	netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: Re: PROBLEM: Injected conntrack lost helper
Date: Wed, 2 Feb 2022 12:48:00 +0100	[thread overview]
Message-ID: <YfpvcDMUw6MJv8kr@salvia> (raw)
In-Reply-To: <20220201120454.GB18351@breakpoint.cc>

On Tue, Feb 01, 2022 at 01:04:54PM +0100, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Tue, Feb 01, 2022 at 10:08:55AM +0700, Pham Thanh Tuyen wrote:
> > > When the conntrack is created, the extension is created before the conntrack
> > > is assigned confirmed and inserted into the hash table. But the function
> > > ctnetlink_setup_nat() causes loss of helper in the mentioned situation. I
> > > mention the template because it's seamless in the
> > > __nf_ct_try_assign_helper() function. Please double check.
> > 
> > Conntrack entries that are created via ctnetlink as IPS_CONFIRMED always
> > set on.
> >
> > The helper code is only exercised from the packet path for conntrack
> > entries that are newly created.
> 
> I suspect this is the most simple fix, might make sense to also
> update the comment of IPS_HELPER to say that it means 'explicitly
> attached via ctnetlink or ruleset'.
> 
> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
> --- a/net/netfilter/nf_conntrack_netlink.c
> +++ b/net/netfilter/nf_conntrack_netlink.c
> @@ -2313,6 +2313,9 @@ ctnetlink_create_conntrack(struct net *net,
>  
>  			/* not in hash table yet so not strictly necessary */
>  			RCU_INIT_POINTER(help->helper, helper);
> +
> +			/* explicitly attached from userspace */
> +			ct->status |= IPS_HELPER;
>  		}
>  	} else {
>  		/* try an implicit helper assignation */

This also LGTM.

I'd suggest you update the .h file to describe that ctnetlink also
sets on this bit.

Thanks

      parent reply	other threads:[~2022-02-02 11:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f9fb5616-0b37-d76b-74e5-53751d473432@gmail.com>
     [not found] ` <3f416429-b1be-b51a-c4ef-6274def33258@iogearbox.net>
     [not found]   ` <0f4edf58-7b4e-05e8-3f13-d34819b8d5db@gmail.com>
2022-01-31 11:20     ` PROBLEM: Injected conntrack lost helper Florian Westphal
2022-01-31 13:47       ` Pham Thanh Tuyen
2022-01-31 13:55         ` Pham Thanh Tuyen
2022-02-01  3:08       ` Pham Thanh Tuyen
2022-02-01 10:29         ` Pablo Neira Ayuso
2022-02-01 12:04           ` Florian Westphal
2022-02-01 13:32             ` Pham Thanh Tuyen
2022-02-01 14:14               ` Florian Westphal
2022-02-02  1:43                 ` Pham Thanh Tuyen
2022-02-02 11:48             ` 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=YfpvcDMUw6MJv8kr@salvia \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phamtyn@gmail.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