lkml.org 
[lkml]   [2011]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] kernel/groups.c: Minor bugfix for overflow in binary search
From
On Thu, Sep 29, 2011 at 9:39 PM, Josh Zimmerman <jzimmerm@andrew.cmu.edu> wrote:
>> Fixed possible unsigned int overflow bug. (2 + 2^(32) - 1)/2 results in overflow; 2 + (2^(32)-1-2)/2 does not.

On Fri, Sep 30, 2011 at 8:44 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> We can't have that many groups anyway, so the overflow is pretty theoretical.
>
> The max should be NGROUPS_MAX, afaik (65536) and other places have
> lower limits (ie sunrpc/nfs). And if some place doesn't limit it
> correctly, we have bigger problems than this (the whole allocation and
> CPU use issues)

The code site could be converted to lib/bsearch.c::bsearch(), AFAICT. That'd
take care of the theoretical overflow too.

Pekka


\
 
 \ /
  Last update: 2011-09-30 09:01    [W:0.052 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site