From: Florian Westphal Subject: Re: [PATCH] netlink: fix memory leak of dump Date: Mon, 23 Jul 2018 12:59:15 +0200 Message-ID: <20180723105915.a6vx5t7htcclez3k@breakpoint.cc> References: <20180722143354.23722-1-cscnull@gmail.com> <20180722163925.gdfkndldatsoae6x@breakpoint.cc> <20180722.100755.19840167505550163.davem@davemloft.net> <20180722180910.wcwhantwpm2nfxet@breakpoint.cc> <20180723091551.mwhltw4ujm4bylvj@salvia> <20180723092818.ztsfsnqzxgzrauim@breakpoint.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Florian Westphal , Pablo Neira Ayuso , David Miller , kadlec , "johannes.berg" , jason , ktkhai , "lucien.xin" , "xiyou.wangcong" , dsahern , netfilter-devel , tom , netdev , linux-kernel To: shaochun chen Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org shaochun chen 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.