Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-25 Thread Andrey Ryabinin
2014-10-25 23:30 GMT+03:00 One Thousand Gnomes : > On Fri, 24 Oct 2014 20:50:46 -0400 > Sasha Levin wrote: > >> On 10/24/2014 06:22 PM, H. Peter Anvin wrote: >> >> By the principle of least surprise, I would expect "__u32 >> N", where >> >> > N >= 32 to return zero instead of random garbage. For

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-25 Thread One Thousand Gnomes
On Fri, 24 Oct 2014 20:50:46 -0400 Sasha Levin wrote: > On 10/24/2014 06:22 PM, H. Peter Anvin wrote: > >> By the principle of least surprise, I would expect "__u32 >> N", where > >> > N >= 32 to return zero instead of random garbage. For N < 32 it will > >> > return progressively smaller number

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Sasha Levin
On 10/24/2014 06:22 PM, H. Peter Anvin wrote: >> By the principle of least surprise, I would expect "__u32 >> N", where >> > N >= 32 to return zero instead of random garbage. For N < 32 it will >> > return progressively smaller numbers, until it has shifted away all of >> > the set bits, at which

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread H. Peter Anvin
On 10/24/2014 03:09 PM, Andreas Dilger wrote: > On Oct 24, 2014, at 9:10 AM, Dmitry Vyukov wrote: >> On Fri, Oct 24, 2014 at 7:04 PM, Sasha Levin wrote: >>> On 10/24/2014 09:42 AM, Peter Zijlstra wrote: On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: > > i >> 32 may happ

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread H. Peter Anvin
On 10/24/2014 02:05 PM, One Thousand Gnomes wrote: > On Fri, 24 Oct 2014 19:10:49 +0400 > Dmitry Vyukov wrote: > >> On Fri, Oct 24, 2014 at 7:04 PM, Sasha Levin wrote: >>> On 10/24/2014 09:42 AM, Peter Zijlstra wrote: On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: > >

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Andreas Dilger
On Oct 24, 2014, at 9:10 AM, Dmitry Vyukov wrote: > On Fri, Oct 24, 2014 at 7:04 PM, Sasha Levin wrote: >> On 10/24/2014 09:42 AM, Peter Zijlstra wrote: >>> On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: i >> 32 may happen to be "i", but is there anything that prevents th

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread One Thousand Gnomes
On Fri, 24 Oct 2014 19:10:49 +0400 Dmitry Vyukov wrote: > On Fri, Oct 24, 2014 at 7:04 PM, Sasha Levin wrote: > > On 10/24/2014 09:42 AM, Peter Zijlstra wrote: > >> On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: > >>> > >>> i >> 32 may happen to be "i", but is there anything that p

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Dmitry Vyukov
On Fri, Oct 24, 2014 at 7:04 PM, Sasha Levin wrote: > On 10/24/2014 09:42 AM, Peter Zijlstra wrote: >> On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: >>> >>> i >> 32 may happen to be "i", but is there anything that prevents the >>> compiler >>> from returning, let's say, 42? >> >> N

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Sasha Levin
On 10/24/2014 09:42 AM, Peter Zijlstra wrote: > On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: >> >> i >> 32 may happen to be "i", but is there anything that prevents the >> compiler >> from returning, let's say, 42? > > Not really, although gcc seems to opt for the 'sane' option an

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Peter Zijlstra
On Fri, Oct 24, 2014 at 09:23:35AM -0400, Sasha Levin wrote: > > i >> 32 may happen to be "i", but is there anything that prevents the compiler > from returning, let's say, 42? Not really, although gcc seems to opt for the 'sane' option and emit the instruction and let the arch figure out how to

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Sasha Levin
On 10/24/2014 06:01 AM, Peter Zijlstra wrote: > On Mon, Oct 20, 2014 at 10:16:35AM -0400, Theodore Ts'o wrote: >> > On Mon, Oct 20, 2014 at 04:09:30PM +0200, Daniel Borkmann wrote: > > > > > >It's triggering when input_rotate == 0, so UBSan complains about > > >right shift in rol32(

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Andrey Ryabinin
On 10/24/2014 02:01 PM, Peter Zijlstra wrote: > On Mon, Oct 20, 2014 at 10:16:35AM -0400, Theodore Ts'o wrote: >> On Mon, Oct 20, 2014 at 04:09:30PM +0200, Daniel Borkmann wrote: It's triggering when input_rotate == 0, so UBSan complains about right shift in rol32() static

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-24 Thread Peter Zijlstra
On Mon, Oct 20, 2014 at 10:16:35AM -0400, Theodore Ts'o wrote: > On Mon, Oct 20, 2014 at 04:09:30PM +0200, Daniel Borkmann wrote: > > > > > >It's triggering when input_rotate == 0, so UBSan complains about right > > >shift in rol32() > > > > > >static inline __u32 rol32(__u32 word, unsigned int sh

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Andrey Ryabinin
On 10/20/2014 06:16 PM, Theodore Ts'o wrote: > On Mon, Oct 20, 2014 at 04:09:30PM +0200, Daniel Borkmann wrote: >>> >>> It's triggering when input_rotate == 0, so UBSan complains about right >>> shift in rol32() >>> >>> static inline __u32 rol32(__u32 word, unsigned int shift) >>> { >>> return

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Theodore Ts'o
On Mon, Oct 20, 2014 at 04:09:30PM +0200, Daniel Borkmann wrote: > > > >It's triggering when input_rotate == 0, so UBSan complains about right shift > >in rol32() > > > >static inline __u32 rol32(__u32 word, unsigned int shift) > >{ > > return (word << shift) | (word >> (32 - shift)); > >} >

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Sasha Levin
On 10/20/2014 10:09 AM, Daniel Borkmann wrote: > On 10/20/2014 03:58 PM, Andrey Ryabinin wrote: >> On 10/20/2014 04:49 PM, Theodore Ts'o wrote: >>> On Mon, Oct 20, 2014 at 03:03:22PM +0400, Andrey Ryabinin wrote: Hi, Theodore. I've got this while booting kernel with ubsan:

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Theodore Ts'o
On Mon, Oct 20, 2014 at 05:58:25PM +0400, Andrey Ryabinin wrote: > It's triggering when input_rotate == 0, so UBSan complains about right shift > in rol32() > > static inline __u32 rol32(__u32 word, unsigned int shift) > { > return (word << shift) | (word >> (32 - shift)); > } Ah, thanks;

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Daniel Borkmann
On 10/20/2014 03:58 PM, Andrey Ryabinin wrote: On 10/20/2014 04:49 PM, Theodore Ts'o wrote: On Mon, Oct 20, 2014 at 03:03:22PM +0400, Andrey Ryabinin wrote: Hi, Theodore. I've got this while booting kernel with ubsan: [0.00] ==

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Andrey Ryabinin
On 10/20/2014 04:49 PM, Theodore Ts'o wrote: > On Mon, Oct 20, 2014 at 03:03:22PM +0400, Andrey Ryabinin wrote: >> Hi, Theodore. >> >> I've got this while booting kernel with ubsan: >> >> [0.00] >> >>

Re: drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Theodore Ts'o
On Mon, Oct 20, 2014 at 03:03:22PM +0400, Andrey Ryabinin wrote: > Hi, Theodore. > > I've got this while booting kernel with ubsan: > > [0.00] > > [0.00] UBSan: Undefined behaviour in > ../i

drivers: random: Shift out-of-bounds in _mix_pool_bytes

2014-10-20 Thread Andrey Ryabinin
Hi, Theodore. I've got this while booting kernel with ubsan: [0.00] [0.00] UBSan: Undefined behaviour in ../include/linux/bitops.h:107:33 [0.00] shift exponent 32 is to large for