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
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 <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
  • Loading branch information
ummakynes authored and Florian Westphal committed Aug 15, 2023
1 parent 6a33d8b commit 02c6c24
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 @@ -9481,9 +9481,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 02c6c24

Please sign in to comment.