[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1324616007.2674.8.camel@edumazet-laptop>
Date: Fri, 23 Dec 2011 05:53:27 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: Xi Wang <xi.wang@...il.com>
Cc: Tom Herbert <therbert@...gle.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: [PATCH v2] rps: fix insufficient bounds checking in
store_rps_dev_flow_table_cnt()
Le jeudi 22 décembre 2011 à 23:44 -0500, Xi Wang a écrit :
> On Dec 22, 2011, at 11:10 PM, Eric Dumazet wrote:
> >> - if (count > 1<<30) {
> >> + if (count > INT_MAX)
> >> + return -EINVAL;
> >> + count = roundup_pow_of_two(count);
> >> + if (count > (ULONG_MAX - sizeof(struct rps_dev_flow_table))
> >
> > Oh well, you added a bug here, since count is "unsigned int"
> >
> > Why mixing INT_MAX in the previous test and ULONG_MAX here ?
>
> The first check (count > INT_MAX) is used to avoid overflowing
> roundup_pow_of_two(count), e.g., when count is 0xffffffff.
>
> The second check is to avoid overflowing the size for vmalloc().
> It gives a less restrictive upper bound than using INT_MAX/UINT_MAX
> on 64-bit platform.
>
> Why do you think it's a bug there? I agree using two checks looks
> ugly though.
>
> - xi
All I wanted to say is that while mixing INT_MAX/ULONG_MAX, you could
have spotted the other bug in the code :
unsigned int count;
count = simple_strtoul(buf, &endp, 0);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists