]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nf_tables: use rcu chain hook list iterator from netlink dump path
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Sep 2024 21:07:46 +0000 (23:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:33:22 +0000 (16:33 +0200)
[ Upstream commit 4ffcf5ca81c3b83180473eb0d3c010a1a7c6c4de ]

Lockless iteration over hook list is possible from netlink dump path,
use rcu variant to iterate over the hook list as is done with flowtable
hooks.

Fixes: b9703ed44ffb ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")
Reported-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nf_tables_api.c

index 3c19928b359c3a96928d201f6390105abe1a3990..71df3e5cc46d91bdb6a82fb62eb3933da3bd3f43 100644 (file)
@@ -1795,7 +1795,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;