Skip to contentSkip to conversation

netfilter: netfilter fixes

PATCH In review [email protected] 2 participants 3 messages Feb 14, 2011

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

cover netfilter: netfilter fixes

Hi Dave,

following is a single netfilter bugfix for 2.6.38, fixing incorrect RCU usage in nf_iterate(). Problem noticed by Eric, patch from myself.

Please apply or pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git master

Thanks!

#1 lore raw

PATCH 1/1 netfilter: nf_iterate: fix incorrect RCU usage

From: Patrick McHardy <[email protected]>

As noticed by Eric, nf_iterate doesn't use RCU correctly by accessing the prev pointer of a RCU protected list element when a verdict of NF_REPEAT is issued.

Fix by jumping backwards to the hook invocation directly instead of loading the previous list element before continuing the list iteration.

---
 net/netfilter/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/netfilter/core.c +2 -1
index 32fcbe2..4aa614b 100644
@@ -133,6 +133,7 @@ unsigned int nf_iterate(struct list_head *head,
 
 		/* Optimization: we don't need to hold module
 		   reference here, since function can't sleep. --RR */
+repeat:
 		verdict = elem->hook(hook, skb, indev, outdev, okfn);
 		if (verdict != NF_ACCEPT) {
 #ifdef CONFIG_NETFILTER_DEBUG
@@ -145,7 +146,7 @@ unsigned int nf_iterate(struct list_head *head,
 #endif
 			if (verdict != NF_REPEAT)
 				return verdict;
-			*i = (*i)->prev;
+			goto repeat;
 		}
 	}
 	return NF_ACCEPT;
Signature · 1 line
1.7.2.3