All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Chen Zhongjin <chenzhongjin@huawei.com>
Cc: linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, kadlec@netfilter.org, fw@strlen.de,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, ast@kernel.org, lorenzo@kernel.org,
	john.fastabend@gmail.com
Subject: Re: [PATCH net v2] netfilter: nf_nat: Fix possible memory leak in nf_nat_init()
Date: Wed, 2 Nov 2022 10:47:00 +0100	[thread overview]
Message-ID: <Y2I8lIldVgo7f3Tc@salvia> (raw)
In-Reply-To: <20221101115252.17340-1-chenzhongjin@huawei.com>

On Tue, Nov 01, 2022 at 07:52:52PM +0800, Chen Zhongjin wrote:
> In nf_nat_init(), register_nf_nat_bpf() can fail and return directly
> without any error handling.
> Then nf_nat_bysource will leak and registering of &nat_net_ops,
> &follow_master_nat and nf_nat_hook won't be reverted.
> 
> This leaves wild ops in linkedlists and when another module tries to
> call register_pernet_operations() or nf_ct_helper_expectfn_register()
> it triggers page fault:
> 
>  BUG: unable to handle page fault for address: fffffbfff81b964c
>  RIP: 0010:register_pernet_operations+0x1b9/0x5f0
>  Call Trace:
>  <TASK>
>   register_pernet_subsys+0x29/0x40
>   ebtables_init+0x58/0x1000 [ebtables]
>   ...
> 
> Fixes: 820dc0523e05 ("net: netfilter: move bpf_ct_set_nat_info kfunc in nf_nat_bpf.c")
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
> Also revert the operation for &follow_master_nat and nf_nat_hook,
> then slightly fix commit msg for it.

Applied, thanks

      reply	other threads:[~2022-11-02  9:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 11:52 [PATCH net v2] netfilter: nf_nat: Fix possible memory leak in nf_nat_init() Chen Zhongjin
2022-11-02  9:47 ` 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=Y2I8lIldVgo7f3Tc@salvia \
    --to=pablo@netfilter.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenzhongjin@huawei.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=john.fastabend@gmail.com \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.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 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.