Skip to content

Commit

Permalink
netfilter: nfqueue: don't use prev pointer
Browse files Browse the repository at this point in the history
Usage of -prev seems buggy.  While packet was out our hook cannot be
removed but we have no way to know if the previous one is still valid.

So better not use ->prev at all.  Since NF_REPEAT just asks to invoke
same hook function again, just do so, and continue with nf_interate
if we get an ACCEPT verdict.

A side effect of this change is that if nf_reinject(NF_REPEAT) causes
another REPEAT we will now drop the skb instead of a kernel loop.

However, NF_REPEAT loops would be a bug so this should not happen anyway.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Oct 13, 2015
1 parent 914eebf commit 7ceebfe
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/netfilter/nf_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
nf_queue_entry_release_refs(entry);

/* Continue traversal iff userspace said ok... */
if (verdict == NF_REPEAT) {
elem = list_entry(elem->list.prev, struct nf_hook_ops, list);
verdict = NF_ACCEPT;
}
if (verdict == NF_REPEAT)
verdict = elem->hook(elem->priv, skb, &entry->state);

if (verdict == NF_ACCEPT) {
afinfo = nf_get_afinfo(entry->state.pf);
Expand Down

0 comments on commit 7ceebfe

Please sign in to comment.