Skip to contentSkip to conversation

netfilter: nf_tables: release flowtable after rcu grace period on error

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Mar 17

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH v2 1/1 netfilter: nf_tables: release flowtable after rcu grace period on error

Call synchronize_rcu() after unregistering the hooks from error path, since a hook that already refers to this flowtable can be already registered, exposing this flowtable to packet path and nfnetlink_hook control plane.

This error path is rare, it should only happen by reaching the maximum number hooks or by failing to set up to hardware offload, just call synchronize_rcu(). There is a check for duplicates but the hook parser already checks this.

Uncovered by KASAN reported as use-after-free from nfnetlink_hook path when dumping hooks.

Fixes 3b49e2e94e6e ("netfilter: nf_tables: add flow table netlink frontend")

---
v2: use synchronize_rcu()

 net/netfilter/nf_tables_api.c | 1 +
 1 file changed, 1 insertion(+)
net/netfilter/nf_tables_api.c +1 -0
index 72c1db7738dc..da82a754ba33 100644
@@ -9155,6 +9155,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
 	return 0;
 
 err_flowtable_hooks:
+	synchronize_rcu();
 	nft_trans_destroy(trans);
 err_flowtable_trans:
 	nft_hooks_destroy(&flowtable->hook_list);
Signature · 1 line
2.47.3