Skip to content

Commit 48351fd

Browse files
committed
netfilter: nf_tables: GC transaction race with netns dismantle
jira VULN-597 subsystem-sync netfilter:nf_tables 4.18.0-534 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 02c6c24 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> (cherry picked from commit 02c6c24) Signed-off-by: Greg Rose <g.v.rose@ciq.com>
1 parent b93cdbe commit 48351fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7902,9 +7902,14 @@ struct nft_trans_gc *nft_trans_gc_alloc(struct nft_set *set,
79027902
if (!trans)
79037903
return NULL;
79047904

7905+
trans->net = maybe_get_net(net);
7906+
if (!trans->net) {
7907+
kfree(trans);
7908+
return NULL;
7909+
}
7910+
79057911
refcount_inc(&set->refs);
79067912
trans->set = set;
7907-
trans->net = get_net(net);
79087913
trans->seq = gc_seq;
79097914

79107915
return trans;
@@ -8161,7 +8166,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
81618166
struct nft_trans_elem *te;
81628167
struct nft_chain *chain;
81638168
struct nft_table *table;
8164-
unsigned int base_seq;
81658169
LIST_HEAD(adl);
81668170
int err;
81678171

0 commit comments

Comments
 (0)