Skip to contentSkip to conversation

netfilter: nftables: fix possible double hook unregistration with table owner

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Mar 4, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nftables: fix possible double hook unregistration with table owner

Skip hook unregistration of owner tables from the netns exit path, nft_rcv_nl_event() unregisters the table hooks before tearing down the table content.

Fixes 6001a930ce03 ("netfilter: nftables: introduce table ownership")
---
 net/netfilter/nf_tables_api.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
net/netfilter/nf_tables_api.c +8 -3
index b07703e19108..495f320b1c93 100644
@@ -9024,12 +9024,17 @@ static void __nft_release_hook(struct net *net, struct nft_table *table)
 		nf_tables_unregister_hook(net, table, chain);
 }
 
-static void __nft_release_hooks(struct net *net)
+static void __nft_release_hooks(struct net *net, u32 nlpid)
 {
 	struct nft_table *table;
 
-	list_for_each_entry(table, &net->nft.tables, list)
+	list_for_each_entry(table, &net->nft.tables, list) {
+		if (nft_table_has_owner(table) &&
+		    nlpid != table->nlpid)
+			continue;
+
 		__nft_release_hook(net, table);
+	}
 }
 
 static void __nft_release_table(struct net *net, struct nft_table *table)
@@ -9143,7 +9148,7 @@ static int __net_init nf_tables_init_net(struct net *net)
 
 static void __net_exit nf_tables_pre_exit_net(struct net *net)
 {
-	__nft_release_hooks(net);
+	__nft_release_hooks(net, 0);
 }
 
 static void __net_exit nf_tables_exit_net(struct net *net)
Signature · 1 line
2.20.1