Re: Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Al Viro
On Mon, Dec 17, 2007 at 06:55:57PM +0100, Eric Dumazet wrote: > long *mid(long *a, long *b) > { > return ((a - b) / 2 + a); > } ... is not actually a middle (you'd want b-a, not a-b there), but anyway > It gave : > mid: > movq%rdi, %rdx > subq%rsi, %rdx > sa

Re: Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Ray Lee
On Dec 17, 2007 10:10 AM, Eric Dumazet <[EMAIL PROTECTED]> wrote: > On Mon, 17 Dec 2007 10:05:35 -0800 > "Ray Lee" <[EMAIL PROTECTED]> wrote: > > > On Dec 17, 2007 9:55 AM, Eric Dumazet <[EMAIL PROTECTED]> wrote: > > > - mid = (last - first) / 2 + first; > > > + while (low <= hi

Re: Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Eric Dumazet
On Mon, 17 Dec 2007 10:05:35 -0800 "Ray Lee" <[EMAIL PROTECTED]> wrote: > On Dec 17, 2007 9:55 AM, Eric Dumazet <[EMAIL PROTECTED]> wrote: > > - mid = (last - first) / 2 + first; > > + while (low <= high) { > > + mid = (low + high) / 2; > > I think you just intro

Re: Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Ray Lee
On Dec 17, 2007 9:55 AM, Eric Dumazet <[EMAIL PROTECTED]> wrote: > - mid = (last - first) / 2 + first; > + while (low <= high) { > + mid = (low + high) / 2; I think you just introduced a bug. Think about what happens if low=high=MAX_LONG/2 + 1. -- To unsubscribe f

Re: Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Eric Dumazet
On Mon, 17 Dec 2007 09:28:57 -0800 (PST) Linus Torvalds <[EMAIL PROTECTED]> wrote: > > > On Sat, 15 Dec 2007, Herbert Xu wrote: > > > > There ought to be a warning about this sort of thing. > > We could add it to sparse. The appended (untested) patch seems to say > there's a lot of those sign

Re: Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Al Viro
On Mon, Dec 17, 2007 at 09:28:57AM -0800, Linus Torvalds wrote: > > > On Sat, 15 Dec 2007, Herbert Xu wrote: > > > > There ought to be a warning about this sort of thing. > > We could add it to sparse. The appended (untested) patch seems to say > there's a lot of those signed divides-by-power-

Signed divides vs shifts (Re: [Security] /dev/urandom uses uninit bytes, leaks user data)

2007-12-17 Thread Linus Torvalds
On Sat, 15 Dec 2007, Herbert Xu wrote: > > There ought to be a warning about this sort of thing. We could add it to sparse. The appended (untested) patch seems to say there's a lot of those signed divides-by-power-of-twos. However, the problem with such warnings is that it encourages people t