Re: [PATCH] netlink: fix memory leak of dump
From: Florian Westphal
Date: Mon Jul 23 2018 - 06:59:29 EST
shaochun chen <cscnull@xxxxxxxxx> 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.