[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wjwt4M7wGcMDkVLmSCsFP3xj29pAVgsC6-zbc_XPN1yiw@mail.gmail.com>
Date: Sun, 20 Jan 2019 17:11:14 +1200
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Florian La Roche <florian.laroche@...glemail.com>
Cc: Will Deacon <will.deacon@....com>,
Linux List Kernel Mailing <linux-kernel@...r.kernel.org>,
Crt Mori <cmo@...exis.com>, Joe Perches <joe@...ches.com>,
Davidlohr Bueso <dave@...olabs.net>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: fix int_sqrt() for very large numbers
On Sun, Jan 20, 2019 at 5:03 PM Florian La Roche
<florian.laroche@...glemail.com> wrote:
>
> The real bug is that we compute 1 to 64 for bit 0 to bit 63, whereas
> the algorithm expects 0 to 63 for the value of m.
Florian, you seem to be in denial.
__fls() returns 0-63. Your patch is *wrong* for the __fls() use,
because when you subtract 1, you get -1 to 62, and the -1 now
introduces the very undefined behavior you claim your patch fixes.
So your patch fixes one real case (int_sqrt64(), that has one user
that doesn't care) but it *BREAKS* the other case that is actually
much more widely used (int_sqrt()).
See what Will and I are complainig about?
Linus
Powered by blists - more mailing lists