Skip to contentSkip to conversation

netfilter: nf_tables: nft_flowtable_find_dev() lacks rcu_read_lock()

PATCH In review Phil Sutter 2 participants 3 messages Sep 19, 2024

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 netfilter: nf_tables: nft_flowtable_find_dev() lacks rcu_read_lock()

Make sure writers won't free the current hook being dereferenced.

Fixes c63a7cc4d795 ("netfilter: flowtable: use dev_fill_forward_path() to obtain ingress device")
---
 net/netfilter/nft_flow_offload.c | 2 ++
 1 file changed, 2 insertions(+)
net/netfilter/nft_flow_offload.c +2 -0
index ab9576098701..8044dbe58ccf 100644
@@ -173,6 +173,7 @@ static bool nft_flowtable_find_dev(const struct net_device *dev,
 	struct nft_hook *hook;
 	bool found = false;
 
+	rcu_read_lock();
 	list_for_each_entry_rcu(hook, &ft->hook_list, list) {
 		if (hook->ops.dev != dev)
 			continue;
@@ -180,6 +181,7 @@ static bool nft_flowtable_find_dev(const struct net_device *dev,
 		found = true;
 		break;
 	}
+	rcu_read_unlock();
 
 	return found;
 }
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 1 line · Phil Sutter

Make sure writers won't free the current hook being dereferenced.

Are you sure?
AFAICS its only called from eval function/hook plane, those are already rcu locked.

author reviewer
#2 lore raw
Quoted 6 lines · Florian Westphal
Quoted 1 line · Phil Sutter

Make sure writers won't free the current hook being dereferenced.

Are you sure?
AFAICS its only called from eval function/hook plane, those are already rcu locked.

Oh, right! I missed the fact that nf_hook() takes care of it already.

So please discard this patch, it's worthless.

Thanks, Phil