From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Thomas Graf <tgraf@suug.ch>
Cc: bart.de.schuymer@pandora.be, kaber@trash.net,
kadlec@blackhole.kfki.hu, stephen@networkplumber.org,
netfilter-devel@vger.kernel.org, Florian Westphal <fw@strlen.de>
Subject: Re: [PATCH] netfilter: Can't fail and free after table replacement
Date: Thu, 3 Apr 2014 23:37:57 +0200 [thread overview]
Message-ID: <20140403213757.GA3834@localhost> (raw)
In-Reply-To: <e9465527b268e8ad308384c839f0b2051da3efb7.1396452712.git.tgraf@suug.ch>
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?
next prev parent reply other threads:[~2014-04-03 21:38 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 [this message]
2014-04-03 22:08 ` Florian Westphal
2014-04-04 8:13 ` 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=20140403213757.GA3834@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 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).