netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: fgao@ikuai8.com
Cc: netfilter-devel@vger.kernel.org, gfree.wind@gmail.com
Subject: Re: [PATCH nf 1/1] netfilter: nat_masquerade: Check oom when invoke nfct_nat
Date: Fri, 3 Mar 2017 10:30:41 +0100	[thread overview]
Message-ID: <20170303093041.GA1461@salvia> (raw)
In-Reply-To: <1488506332-21265-1-git-send-email-fgao@ikuai8.com>

On Fri, Mar 03, 2017 at 09:58:52AM +0800, fgao@ikuai8.com wrote:
> From: Gao Feng <fgao@ikuai8.com>
> 
> When memory is exhausted, nf_ct_nat_ext_add may return NULL. Then
> nf_nat_ipv4_fn and nf_nat_ipv6_fn would return NF_ACCEPT in this
> case.
> So we need add the NULL check when invoke nfct_nat in these two
> functions.
> 
> Signed-off-by: Gao Feng <fgao@ikuai8.com>
> ---
>  net/ipv4/netfilter/nf_nat_masquerade_ipv4.c | 2 ++
>  net/ipv6/netfilter/nf_nat_masquerade_ipv6.c | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/netfilter/nf_nat_masquerade_ipv4.c b/net/ipv4/netfilter/nf_nat_masquerade_ipv4.c
> index ea91058..353ca0c 100644
> --- a/net/ipv4/netfilter/nf_nat_masquerade_ipv4.c
> +++ b/net/ipv4/netfilter/nf_nat_masquerade_ipv4.c
> @@ -38,6 +38,8 @@
>  
>  	ct = nf_ct_get(skb, &ctinfo);
>  	nat = nfct_nat(ct);
> +	if (!nat)
> +		return NF_ACCEPT;

The masquerade target is only called from the nat table. If you look
at nf_nat_ipv4_fn(), that is called whenever the packet enters a nat
table, you can indeed check that nfct_nat() must be already there by
when we call masquerade.

So this is entirely unnecessary.

  reply	other threads:[~2017-03-03 10:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03  1:58 [PATCH nf 1/1] netfilter: nat_masquerade: Check oom when invoke nfct_nat fgao
2017-03-03  9:30 ` Pablo Neira Ayuso [this message]
2017-03-03  9:53   ` Gao Feng

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=20170303093041.GA1461@salvia \
    --to=pablo@netfilter.org \
    --cc=fgao@ikuai8.com \
    --cc=gfree.wind@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).