From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: coreteam@netfilter.org, netdev@vger.kernel.org,
bridge@lists.linux-foundation.org,
kernel-janitors@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Stephen Hemminger <stephen@networkplumber.org>,
netfilter@vger.kernel.org,
Bart De Schuymer <bart.de.schuymer@pandora.be>,
netfilter-devel@vger.kernel.org,
Patrick McHardy <kaber@trash.net>
Subject: Re: [Bridge] [patch] netfilter: prevent harmless integer overflow
Date: Thu, 20 Jun 2013 14:09:44 +0300 [thread overview]
Message-ID: <20130620110944.GS5008@mwanda> (raw)
In-Reply-To: <20130620102352.GA19813@localhost>
On Thu, Jun 20, 2013 at 12:23:52PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Jun 18, 2013 at 10:46:03AM +0300, Dan Carpenter wrote:
> > This overflow is harmless because a few lines later we check:
> >
> > if (num_counters != t->private->nentries) {
> >
> > But it still upsets the static checkers.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> > index 3d110c4..141350e 100644
> > --- a/net/bridge/netfilter/ebtables.c
> > +++ b/net/bridge/netfilter/ebtables.c
> > @@ -1278,6 +1278,8 @@ static int do_update_counters(struct net *net, const char *name,
> >
> > if (num_counters == 0)
> > return -EINVAL;
> > + if (num_counters > INT_MAX / sizeof(*tmp))
> > + return -ENOMEM;
>
> This is artificially limiting to INT_MAX / sizeof(struct counters).
> Before this patch, the limit is UINT_MAX / sizeof(struct counters). I
> think it's very unlikely to hit such a limit though, but as you
> mentioned we cover the overflow already. Adding it to calm down a
> static checker sound a bit too much for me.
I think we may be talking about different things?
"num_counters" comes from the user in update_counters() and we can
definitely overflow. I just copied the checks from do_replace() so
that's why it uses INT_MAX instead of UINT_MAX.
Like I said, the overflow is not harmful because later in the
function we check "(num_counters != t->private->nentries)" and
return an error before using "tmp". So I don't feel strongly about
this patch either way.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: coreteam@netfilter.org, netdev@vger.kernel.org,
bridge@lists.linux-foundation.org,
kernel-janitors@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Stephen Hemminger <stephen@networkplumber.org>,
netfilter@vger.kernel.org,
Bart De Schuymer <bart.de.schuymer@pandora.be>,
netfilter-devel@vger.kernel.org,
Patrick McHardy <kaber@trash.net>
Subject: Re: [patch] netfilter: prevent harmless integer overflow
Date: Thu, 20 Jun 2013 11:09:44 +0000 [thread overview]
Message-ID: <20130620110944.GS5008@mwanda> (raw)
In-Reply-To: <20130620102352.GA19813@localhost>
On Thu, Jun 20, 2013 at 12:23:52PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Jun 18, 2013 at 10:46:03AM +0300, Dan Carpenter wrote:
> > This overflow is harmless because a few lines later we check:
> >
> > if (num_counters != t->private->nentries) {
> >
> > But it still upsets the static checkers.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> > index 3d110c4..141350e 100644
> > --- a/net/bridge/netfilter/ebtables.c
> > +++ b/net/bridge/netfilter/ebtables.c
> > @@ -1278,6 +1278,8 @@ static int do_update_counters(struct net *net, const char *name,
> >
> > if (num_counters = 0)
> > return -EINVAL;
> > + if (num_counters > INT_MAX / sizeof(*tmp))
> > + return -ENOMEM;
>
> This is artificially limiting to INT_MAX / sizeof(struct counters).
> Before this patch, the limit is UINT_MAX / sizeof(struct counters). I
> think it's very unlikely to hit such a limit though, but as you
> mentioned we cover the overflow already. Adding it to calm down a
> static checker sound a bit too much for me.
I think we may be talking about different things?
"num_counters" comes from the user in update_counters() and we can
definitely overflow. I just copied the checks from do_replace() so
that's why it uses INT_MAX instead of UINT_MAX.
Like I said, the overflow is not harmful because later in the
function we check "(num_counters != t->private->nentries)" and
return an error before using "tmp". So I don't feel strongly about
this patch either way.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: coreteam@netfilter.org, netdev@vger.kernel.org,
bridge@lists.linux-foundation.org,
kernel-janitors@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Stephen Hemminger <stephen@networkplumber.org>,
netfilter@vger.kernel.org,
Bart De Schuymer <bart.de.schuymer@pandora.be>,
netfilter-devel@vger.kernel.org,
Patrick McHardy <kaber@trash.net>
Subject: Re: [patch] netfilter: prevent harmless integer overflow
Date: Thu, 20 Jun 2013 14:09:44 +0300 [thread overview]
Message-ID: <20130620110944.GS5008@mwanda> (raw)
In-Reply-To: <20130620102352.GA19813@localhost>
On Thu, Jun 20, 2013 at 12:23:52PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Jun 18, 2013 at 10:46:03AM +0300, Dan Carpenter wrote:
> > This overflow is harmless because a few lines later we check:
> >
> > if (num_counters != t->private->nentries) {
> >
> > But it still upsets the static checkers.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> > index 3d110c4..141350e 100644
> > --- a/net/bridge/netfilter/ebtables.c
> > +++ b/net/bridge/netfilter/ebtables.c
> > @@ -1278,6 +1278,8 @@ static int do_update_counters(struct net *net, const char *name,
> >
> > if (num_counters == 0)
> > return -EINVAL;
> > + if (num_counters > INT_MAX / sizeof(*tmp))
> > + return -ENOMEM;
>
> This is artificially limiting to INT_MAX / sizeof(struct counters).
> Before this patch, the limit is UINT_MAX / sizeof(struct counters). I
> think it's very unlikely to hit such a limit though, but as you
> mentioned we cover the overflow already. Adding it to calm down a
> static checker sound a bit too much for me.
I think we may be talking about different things?
"num_counters" comes from the user in update_counters() and we can
definitely overflow. I just copied the checks from do_replace() so
that's why it uses INT_MAX instead of UINT_MAX.
Like I said, the overflow is not harmful because later in the
function we check "(num_counters != t->private->nentries)" and
return an error before using "tmp". So I don't feel strongly about
this patch either way.
regards,
dan carpenter
next prev parent reply other threads:[~2013-06-20 11:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 7:46 [Bridge] [patch] netfilter: prevent harmless integer overflow Dan Carpenter
2013-06-18 7:46 ` Dan Carpenter
2013-06-18 7:46 ` Dan Carpenter
2013-06-20 10:23 ` [Bridge] " Pablo Neira Ayuso
2013-06-20 10:23 ` Pablo Neira Ayuso
2013-06-20 10:23 ` Pablo Neira Ayuso
2013-06-20 11:09 ` Dan Carpenter [this message]
2013-06-20 11:09 ` Dan Carpenter
2013-06-20 11:09 ` Dan Carpenter
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=20130620110944.GS5008@mwanda \
--to=dan.carpenter@oracle.com \
--cc=bart.de.schuymer@pandora.be \
--cc=bridge@lists.linux-foundation.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=stephen@networkplumber.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.