netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: shaochun chen <cscnull@gmail.com>
Cc: Florian Westphal <fw@strlen.de>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	David Miller <davem@davemloft.net>,
	kadlec <kadlec@blackhole.kfki.hu>,
	"johannes.berg" <johannes.berg@intel.com>,
	jason <Jason@zx2c4.com>, ktkhai <ktkhai@virtuozzo.com>,
	"lucien.xin" <lucien.xin@gmail.com>,
	"xiyou.wangcong" <xiyou.wangcong@gmail.com>,
	dsahern <dsahern@gmail.com>,
	netfilter-devel <netfilter-devel@vger.kernel.org>,
	tom <tom@quantonium.net>, netdev <netdev@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] netlink: fix memory leak of dump
Date: Mon, 23 Jul 2018 12:59:15 +0200	[thread overview]
Message-ID: <20180723105915.a6vx5t7htcclez3k@breakpoint.cc> (raw)
In-Reply-To: <CAKDdixBBd08eKvk-hJtwPy46u2uzihRCh_KdEMF3xG1ZJ6oNsg@mail.gmail.com>

shaochun chen <cscnull@gmail.com> wrote:
> I have a question: we will try_module_get in __netlink_dump_start(),

Thats too late, we release rcu read lock before this, so the module
implementing ->dump might have been removed already.

> but why we need to call try_module_get again in  nft_netlink_dump_start ??

Its the other way around.
This is the first try_module_get; at this point we still hold rcu read
lock.

If nf_tables module is being removed, try_module_get will fail and
we can error out.

If it succeeds, its safe to drop the rcu read lock.

      parent reply	other threads:[~2018-07-23 10:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-22 14:33 [PATCH] netlink: fix memory leak of dump Shaochun Chen
2018-07-22 16:39 ` Florian Westphal
2018-07-22 17:07   ` David Miller
2018-07-22 18:09     ` Florian Westphal
2018-07-23  2:05       ` shaochun chen
2018-07-23  9:15       ` Pablo Neira Ayuso
2018-07-23  9:28         ` Florian Westphal
2018-07-23  9:38           ` Pablo Neira Ayuso
2018-07-23  9:42             ` Florian Westphal
2018-07-23  9:47               ` Pablo Neira Ayuso
2018-07-23 10:51                 ` Florian Westphal
2018-07-23  9:52           ` shaochun chen
2018-07-23 10:34             ` shaochun chen
2018-07-23 10:43               ` Pablo Neira Ayuso
2018-07-23 10:59               ` Florian Westphal [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=20180723105915.a6vx5t7htcclez3k@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=Jason@zx2c4.com \
    --cc=cscnull@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=johannes.berg@intel.com \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=ktkhai@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=tom@quantonium.net \
    --cc=xiyou.wangcong@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;
as well as URLs for NNTP newsgroup(s).