Skip to content

Commit

Permalink
netfilter: nf_tables: GC transaction race with netns dismantle
Browse files Browse the repository at this point in the history
commit 02c6c24 upstream.

Use maybe_get_net() since GC workqueue might race with netns exit path.

Fixes: 5f68718 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ummakynes authored and gregkh committed Oct 6, 2023
1 parent 41113aa commit afa584c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -9155,9 +9155,14 @@ struct nft_trans_gc *nft_trans_gc_alloc(struct nft_set *set,
if (!trans)
return NULL;

trans->net = maybe_get_net(net);
if (!trans->net) {
kfree(trans);
return NULL;
}

refcount_inc(&set->refs);
trans->set = set;
trans->net = get_net(net);
trans->seq = gc_seq;

return trans;
Expand Down

0 comments on commit afa584c

Please sign in to comment.