[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <C0DC969A-A32B-4CC8-B565-FF741E9D75DA@gmail.com>
Date: Thu, 22 Dec 2011 23:44:51 -0500
From: Xi Wang <xi.wang@...il.com>
To: Eric Dumazet <eric.dumazet@...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()
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
--
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