Skip to contentSkip to conversation

netfilter: add list element test to br_netfilter_hooks

PATCH New Aaron Conole 1 participant 1 message Dec 6, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: add list element test to br_netfilter_hooks

The for-loop in the bridge hook entries assumes that the elements are always present. However, this assumption may not always be true.

Fixes 66cfc1dd07c7 ("netfilter: convert while loops to for loops")

--
Pablo, if possible could this be squashed into the commit instead? I only did a build test of this, but it should be correct.

net/bridge/br_netfilter_hooks.c +1 -1
index fbe35b4..b12501a 100644
@@ -1009,7 +1009,7 @@ int br_nf_hook_thresh(unsigned int hook, struct net *net,
 	int ret;
 
 	for (elem = rcu_dereference(net->nf.hooks[NFPROTO_BRIDGE][hook]);
-	     nf_hook_entry_priority(elem) <= NF_BR_PRI_BRNF;
+	     elem && nf_hook_entry_priority(elem) <= NF_BR_PRI_BRNF;
 	     elem = rcu_dereference(elem->next))
 		;
 

--
2.5.0