path: root/net
diff options
authorPatrick McHardy <kaber@trash.net>2011-02-14 17:35:07 +0100
committerPatrick McHardy <kaber@trash.net>2011-02-14 17:35:07 +0100
commitde9963f0f2dfad128b26ae7bf6005f5948416a6d (patch)
tree73b45541d33e86600cd10e4be43298864f2b6a1a /net
parentnetfilter: nf_conntrack: set conntrack templates again if we return NF_REPEAT (diff)
netfilter: nf_iterate: fix incorrect RCU usage
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. Reported-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net')
1 files changed, 2 insertions, 1 deletions
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 32fcbe290c04..4aa614b8a96a 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -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 */
verdict = elem->hook(hook, skb, indev, outdev, okfn);
if (verdict != NF_ACCEPT) {
@@ -145,7 +146,7 @@ unsigned int nf_iterate(struct list_head *head,
if (verdict != NF_REPEAT)
return verdict;
- *i = (*i)->prev;
+ goto repeat;
return NF_ACCEPT;