netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org, dvyukov@google.com
Subject: Re: [PATCH nf] netfilter: nftables: accept all dummy chain when table is dormant
Date: Wed, 19 May 2021 11:01:50 +0200	[thread overview]
Message-ID: <20210519090150.GA30723@salvia> (raw)
In-Reply-To: <20210519083028.GB8317@breakpoint.cc>

On Wed, May 19, 2021 at 10:30:28AM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Wed, May 19, 2021 at 12:56:19AM +0200, Florian Westphal wrote:
> > > Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > > The dormant flag need to be updated from the preparation phase,
> > > > otherwise, two consecutive requests to dorm a table in the same batch
> > > > might try to remove the same hooks twice, resulting in the following
> > > > warning:
> > > > 
> > > >  hook not found, pf 3 num 0
> > > >  WARNING: CPU: 0 PID: 334 at net/netfilter/core.c:480 __nf_unregister_net_hook+0x1eb/0x610 net/netfilter/core.c:480
> > > >  Modules linked in:
> > > >  CPU: 0 PID: 334 Comm: kworker/u4:5 Not tainted 5.12.0-syzkaller #0
> > > >  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> > > >  Workqueue: netns cleanup_net
> > > >  RIP: 0010:__nf_unregister_net_hook+0x1eb/0x610 net/netfilter/core.c:480
> > > 
> > > Would it be possible to reject such a batch instead of having to add
> > > rely on dummy hooking instead?
> > 
> > That's a simple way to fix it, yes, ie. hit EBUSY.
> > 
> > > I don't think we should try to be clever with nonsensical yes-no-yes-yes-no
> > > type commits.
> > 
> > Note that no such EBUSY limitation exists so far in the transaction
> > semantics that I know [*]. We already discussed that robots might do
> > non-sensical stuff when creating a batches, and reporting EBUSY for
> > this add-del-add case might just break them.
> 
> I don't think this breaks existing users, noone except syzbot
> reported such WARN splat so far.
> 
> > This also removes the conditional hook registration, so hooks are
> > registered once at chain creation. This simplifies interaction with
> > the netfilter core at the cost of adding complexity to
> > nf_tables_commit_chain_prepare() path.
> 
> It also adds side effect (hook registration) during preparation phase.

Chain hook registration always happened from preparation phase before
this patch.

> I think its similar to
> 
> add table foo
> delete table foo
> delete table foo
> 
> ... and that gives -ENOENT.

This is the preparation phase that is rejecting it with -ENOENT.

The sequence that this patch handles is similar to:

add table foo
delete table foo
add table foo

which does _not_ hit EBUSY.

The existing transaction semantics handles similar sequences for the
existing objects.

This patch ensures that:

add table x
add chain x y { type filter hook input priority 0; }
add table x { flags dormant; }
add table x { ; }

in a batch file works fine.

A robot could generate such sequence above.

  reply	other threads:[~2021-05-19  9:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 22:47 [PATCH nf] netfilter: nftables: accept all dummy chain when table is dormant Pablo Neira Ayuso
2021-05-18 22:56 ` Florian Westphal
2021-05-18 23:18   ` Pablo Neira Ayuso
2021-05-19  8:30     ` Florian Westphal
2021-05-19  9:01       ` Pablo Neira Ayuso [this message]
2021-05-19  9:07         ` Pablo Neira Ayuso

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=20210519090150.GA30723@salvia \
    --to=pablo@netfilter.org \
    --cc=dvyukov@google.com \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).