From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Aaron Conole <aconole@bytheb.org>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf,v2] netfilter: nf_queue: don't re-enter same hook on packet reinjection
Date: Tue, 18 Oct 2016 17:45:10 +0200 [thread overview]
Message-ID: <20161018154510.GD29405@breakpoint.cc> (raw)
In-Reply-To: <20161018153456.GA2739@salvia>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Mon, Oct 17, 2016 at 03:29:27PM -0400, Aaron Conole wrote:
> > Pablo Neira Ayuso <pablo@netfilter.org> writes:
> [...]
> > > From c1a731c68791bcd504a7fe5d28f5f0fd59d66118 Mon Sep 17 00:00:00 2001
> > > From: Pablo Neira Ayuso <pablo@netfilter.org>
> > > Date: Thu, 13 Oct 2016 08:14:03 +0200
> > > Subject: [PATCH nf,v3] netfilter: nf_queue: don't re-enter same hook on packet
> > > reinjection
> > >
> > > If the packet is accepted, we have to skip the current hook from where
> > > the packet was enqueued. Thus, we can emulate the previous
> > > list_for_each_entry_continue() behaviour happening from nf_reinject(),
> > > otherwise the packets gets enqueued over and over again.
> > >
> > > Fixes: e3b37f11e6e4 ("netfilter: replace list_head with single linked list")
> > > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > > ---
> > > net/netfilter/nf_queue.c | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
> > > index 96964a0070e1..0b5ac3c9c2bc 100644
> > > --- a/net/netfilter/nf_queue.c
> > > +++ b/net/netfilter/nf_queue.c
> > > @@ -187,8 +187,10 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
> > > entry->state.thresh = INT_MIN;
> > >
> > > if (verdict == NF_ACCEPT) {
> > > - next_hook:
> > > - verdict = nf_iterate(skb, &entry->state, &hook_entry);
> > > + hook_entry = rcu_dereference(hook_entry->next);
> > > + if (hook_entry)
> > > +next_hook:
> >
> > Should the above two lines be transposed to this?
> >
> > next_hook:
> > if (hook_entry)
> >
> > Sorry if I'm misunderstanding it. Too many special cases for my tiny
> > brain...
>
> Right, my patch is still not correct.
>
> I think this should be it:
>
> if (verdict == NF_ACCEPT) {
> next_hook:
> hook_entry = rcu_dereference(hook_entry->next);
> if (hook_entry)
> verdict = nf_iterate(skb, &entry->state, &hook_entry);
>
> So we jump to "next_hook" in case of NF_QUEUE verdict with bypass flag
> set on. In that case, we need to continue just after the current hook
> entry to emulate the behaviour that we previously have via
> list_for_each_entry_continue().
>
> This NF_QUEUE handling is also broken from nf_hook_slow() path, right?
Yes. As you already indicate, list_for_each_entry_continue() resumes
after the current elem, this isn't true anymore.
So for nf_queue we need to move to hook_entry->next in ACCEPT case,
and, for nf_hook_slow, we need to do the same when hitting
(verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
goto next_hook;
branch.
next prev parent reply other threads:[~2016-10-18 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-14 10:37 [PATCH nf,v2] netfilter: nf_queue: don't re-enter same hook on packet reinjection Pablo Neira Ayuso
2016-10-17 15:23 ` Aaron Conole
2016-10-17 17:03 ` Pablo Neira Ayuso
2016-10-17 19:29 ` Aaron Conole
2016-10-18 15:34 ` Pablo Neira Ayuso
2016-10-18 15:45 ` Florian Westphal [this message]
2016-10-18 19:20 ` Aaron Conole
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161018154510.GD29405@breakpoint.cc \
--to=fw@strlen.de \
--cc=aconole@bytheb.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.