Skip to contentSkip to conversation

netfilter: nf_tables: use rcu chain hook list iterator from netlink dump path

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Sep 17, 2024

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nf_tables: use rcu chain hook list iterator from netlink dump path

Lockless iteration over the list of hooks is possible from the netlink dump path while updates can occur. Use the rcu variant to iterate over the hook list as is done for flow table hooks.

Fixes b9703ed44ffb ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")

---
As a result from discussing recent Phil's patch 1/16 to add dynamic hook interface binding.

 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index 045ae805adbc..2e1063b58311 100644
@@ -1841,7 +1841,7 @@ static int nft_dump_basechain_hook(struct sk_buff *skb, int family,
 		if (!hook_list)
 			hook_list = &basechain->hook_list;
 
-		list_for_each_entry(hook, hook_list, list) {
+		list_for_each_entry_rcu(hook, hook_list, list) {
 			if (!first)
 				first = hook;
 
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 3 lines · Pablo Neira Ayuso

Lockless iteration over the list of hooks is possible from the netlink dump path while updates can occur. Use the rcu variant to iterate over the hook list as is done for flow table hooks.

Thanks for following up, this indeed needs _rcu variant.