All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: Thomas Graf <tgraf@suug.ch>,
	bart.de.schuymer@pandora.be, kaber@trash.net,
	kadlec@blackhole.kfki.hu, stephen@networkplumber.org,
	netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: Can't fail and free after table replacement
Date: Fri, 4 Apr 2014 10:13:14 +0200	[thread overview]
Message-ID: <20140404081314.GB3548@localhost> (raw)
In-Reply-To: <20140403220826.GC6769@breakpoint.cc>

On Fri, Apr 04, 2014 at 12:08:26AM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Wed, Apr 02, 2014 at 05:35:13PM +0200, Thomas Graf wrote:
> > > All xtables variants suffer from the defect that the copy_to_user()
> > > to copy the counters to user memory may fail after the table has
> > > already been exchanged and thus exposed. Return an error at this
> > > point will result in freeing the already exposed table. Any
> > > subsequent packet processing will result in a kernel panic.
> > > 
> > > We can't copy the counters before exposing the new tables as we
> > > want provide the counter state after the old table has been
> > > unhooked. Therefore convert this into a silent error.
> > > 
> > > Cc: Florian Westphal <fw@strlen.de>
> > > Signed-off-by: Thomas Graf <tgraf@suug.ch>
> > > ---
> > >  net/bridge/netfilter/ebtables.c | 4 +---
> > >  net/ipv4/netfilter/arp_tables.c | 5 +++--
> > >  net/ipv4/netfilter/ip_tables.c  | 5 +++--
> > >  net/ipv6/netfilter/ip6_tables.c | 5 +++--
> > >  4 files changed, 10 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> > > index 0e474b1..7a3dc98 100644
> > > --- a/net/bridge/netfilter/ebtables.c
> > > +++ b/net/bridge/netfilter/ebtables.c
> > > @@ -1044,10 +1044,8 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
> > >  	if (repl->num_counters &&
> > >  	   copy_to_user(repl->counters, counterstmp,
> > >  	   repl->num_counters * sizeof(struct ebt_counter))) {
> > > -		ret = -EFAULT;
> > > +		/* Silent error, can't fail, new table is already in place */
> > >  	}
> > > -	else
> > > -		ret = 0;
> > >  
> > 
> > This seems good to me.
> > 
> > Perhaps we can spot a warning like in rtnetlink to inform the user
> > that counters are not reliable anymore?
> 
> you mean net_warn_ratelimit() ?
> 
> Sure, can be added.
> 
> However given that this bug has been around for 9 years I don't think
> its really needed, if it fails kernel panic'd, so its safe to say
> that the counters are reliable ;)

But we are not crashing anymore, right? That swapped out scenario may
happen in a short-time stress situation from the memory POV. Let's
just be informative, it's just one extra line ahead.

      reply	other threads:[~2014-04-04  8:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02 15:35 [PATCH] netfilter: Can't fail and free after table replacement Thomas Graf
2014-04-03 21:37 ` Pablo Neira Ayuso
2014-04-03 22:08   ` Florian Westphal
2014-04-04  8:13     ` Pablo Neira Ayuso [this message]

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=20140404081314.GB3548@localhost \
    --to=pablo@netfilter.org \
    --cc=bart.de.schuymer@pandora.be \
    --cc=fw@strlen.de \
    --cc=kaber@trash.net \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=tgraf@suug.ch \
    /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.