diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-08-15 15:39:01 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2023-08-16 00:05:15 +0200 |
commit | 02c6c24402bf1c1e986899c14ba22a10b510916b (patch) | |
tree | a3f1e53b7225c02c4793e51ab8e67736d49dec24 /net/netfilter | |
parent | 6a33d8b73dfac0a41f3877894b38082bd0c9a5bc (diff) |
netfilter: nf_tables: GC transaction race with netns dismantle
Use maybe_get_net() since GC workqueue might race with netns exit path.
Fixes: 5f68718b34a5 ("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>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nf_tables_api.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 8ac4dd8be1a2..3e841e45f2c0 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -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; |