Re: [PATCH] netfilter: Cleanup nft_net->module_list from nf_tables_exit_net()

From: Florian Westphal
Date: Thu Nov 03 2022 - 09:18:44 EST


Shigeru Yoshida <syoshida@xxxxxxxxxx> wrote:
> syzbot reported a warning like below [1]:
>
> This patch fixes this issue by calling __nf_tables_abort() when
> nft_net->module_list is not empty in nf_tables_exit_net().

Fixes: eb014de4fd41 ("netfilter: nf_tables: autoload modules from the abort path")

> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index 58d9cbc9ccdc..a7579d16f59f 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -10088,7 +10088,8 @@ static void __net_exit nf_tables_exit_net(struct net *net)
> struct nftables_pernet *nft_net = nft_pernet(net);
>
> mutex_lock(&nft_net->commit_mutex);
> - if (!list_empty(&nft_net->commit_list))
> + if (!list_empty(&nft_net->commit_list) ||
> + !list_empty(&nft_net->module_list))
> __nf_tables_abort(net, NFNL_ABORT_NONE);

Maybe just an unconditionall call to nf_tables_module_autoload_cleanup().

Or, alternatively, unconditionally call __nf_tables_abort().
The downside is that we will need to change __nf_tables_abort to elide
synchronize_rcu() unless needed -- else netns dismantling might become
too expensive.

OTOH, module_list should always be empty here, so this is ok.

Reviewed-by: Florian Westphal <fw@xxxxxxxxx>