* [patch] netfilter: prevent harmless integer overflow
@ 2013-06-18 7:46 Dan Carpenter
2013-06-20 10:23 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2013-06-18 7:46 UTC (permalink / raw)
To: Bart De Schuymer
Cc: coreteam, netdev, bridge, kernel-janitors, David S. Miller,
Stephen Hemminger, netfilter, netfilter-devel, Patrick McHardy,
Pablo Neira Ayuso
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;
tmp = vmalloc(num_counters * sizeof(*tmp));
if (!tmp)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] netfilter: prevent harmless integer overflow
2013-06-18 7:46 [patch] netfilter: prevent harmless integer overflow Dan Carpenter
@ 2013-06-20 10:23 ` Pablo Neira Ayuso
2013-06-20 11:09 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2013-06-20 10:23 UTC (permalink / raw)
To: Dan Carpenter
Cc: Bart De Schuymer, Patrick McHardy, Stephen Hemminger,
David S. Miller, netfilter-devel, netfilter, coreteam, bridge,
netdev, kernel-janitors
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] netfilter: prevent harmless integer overflow
2013-06-20 10:23 ` Pablo Neira Ayuso
@ 2013-06-20 11:09 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-06-20 11:09 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: coreteam, netdev, bridge, kernel-janitors, David S. Miller,
Stephen Hemminger, netfilter, Bart De Schuymer, netfilter-devel,
Patrick McHardy
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-20 11:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18 7:46 [patch] netfilter: prevent harmless integer overflow Dan Carpenter
2013-06-20 10:23 ` Pablo Neira Ayuso
2013-06-20 11:09 ` Dan Carpenter
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).