netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Xin Long <lucien.xin@gmail.com>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de, fgao@ikuai8.com
Subject: Re: [PATCH net] netfilter: check for seqadj ext existence before adding it in nf_nat_setup_info
Date: Thu, 24 Aug 2017 16:10:44 +0200	[thread overview]
Message-ID: <20170824141044.GA2369@salvia> (raw)
In-Reply-To: <941d1a239dcfb3e47b42f8f717ada3029b3adabb.1502331744.git.lucien.xin@gmail.com>

On Thu, Aug 10, 2017 at 10:22:24AM +0800, Xin Long wrote:
> Commit 4440a2ab3b9f ("netfilter: synproxy: Check oom when adding synproxy
> and seqadj ct extensions") wanted to drop the packet when it fails to add
> seqadj ext due to no memory by checking if nfct_seqadj_ext_add returns
> NULL.
> 
> But that nfct_seqadj_ext_add returns NULL can also happen when seqadj ext
> already exists in a nf_conn. It will cause that userspace protocol doesn't
> work when both dnat and snat are configured.
> 
> Li Shuang found this issue in the case:
> 
> Topo:
>    ftp client                   router                  ftp server
>   10.167.131.2  <-> 10.167.131.254  10.167.141.254 <-> 10.167.141.1
> 
> Rules:
>   # iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 21 -j \
>     DNAT --to-destination 10.167.141.1
>   # iptables -t nat -A POSTROUTING -o eth2 -p tcp -m tcp --dport 21 -j \
>     SNAT --to-source 10.167.141.254
> 
> In router, when both dnat and snat are added, nf_nat_setup_info will be
> called twice. The packet can be dropped at the 2nd time for DNAT due to
> seqadj ext is already added at the 1st time for SNAT.
> 
> This patch is to fix it by checking for seqadj ext existence before adding
> it, so that the packet will not be dropped if seqadj ext already exists.

Applied, thanks.

> Note that as Florian mentioned, as a long term, we should review ext_add()
> behaviour, it's better to return a pointer to the existing ext instead.

That seems very reasonable to me, it would be good to see if a change
like that simplifies things.

      reply	other threads:[~2017-08-24 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10  2:22 [PATCH net] netfilter: check for seqadj ext existence before adding it in nf_nat_setup_info Xin Long
2017-08-24 14:10 ` 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=20170824141044.GA2369@salvia \
    --to=pablo@netfilter.org \
    --cc=fgao@ikuai8.com \
    --cc=fw@strlen.de \
    --cc=lucien.xin@gmail.com \
    --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 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).