Re: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-09 Thread Pavel Machek
Hi! > (resend, cc Andrey) > > On Sun, 7 Apr 2019 12:53:25 + Vadim Pasternak > wrote: > > > The warning is caused by call to rorXX(), if the second parameters of > > this function "shift" is zero. In such case UBSAN reports the warning > > for the next expression: (word << (XX - shift),

Re: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-09 Thread Rasmus Villemoes
On 09/04/2019 10.08, Rasmus Villemoes wrote: > one could do > > u32 ror32(u32 x, unsigned s) > { > return (x >> (s&31)) | (x << ((32-s)&31)); > } > > to make the shifts always well-defined and also work as expected for s > >= 32... if only gcc recognized that the masking is redundant, so

Re: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-09 Thread Rasmus Villemoes
On 09/04/2019 00.52, Andrew Morton wrote: > (resend, cc Andrey) > > On Sun, 7 Apr 2019 12:53:25 + Vadim Pasternak > wrote: > >> The warning is caused by call to rorXX(), if the second parameters of >> this function "shift" is zero. In such case UBSAN reports the warning >> for the next

RE: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-09 Thread Vadim Pasternak
ct: Re: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning > for rotation right > > (resend, cc Andrey) > > On Sun, 7 Apr 2019 12:53:25 + Vadim Pasternak > wrote: > > > The warning is caused by call to rorXX(), if the second parameters of > >

Re: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-08 Thread Andrew Morton
(resend, cc Andrey) On Sun, 7 Apr 2019 12:53:25 + Vadim Pasternak wrote: > The warning is caused by call to rorXX(), if the second parameters of > this function "shift" is zero. In such case UBSAN reports the warning > for the next expression: (word << (XX - shift), where XX is > 64, 32,

Re: [PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-08 Thread Andrew Morton
On Sun, 7 Apr 2019 12:53:25 + Vadim Pasternak wrote: > The warning is caused by call to rorXX(), if the second parameters of > this function "shift" is zero. In such case UBSAN reports the warning > for the next expression: (word << (XX - shift), where XX is > 64, 32, 16, 8 for respectively

[PATCH v1 bitops] bitops: Fix UBSAN undefined behavior warning for rotation right

2019-04-07 Thread Vadim Pasternak
The warning is caused by call to rorXX(), if the second parameters of this function "shift" is zero. In such case UBSAN reports the warning for the next expression: (word << (XX - shift), where XX is 64, 32, 16, 8 for respectively ror64, ror32, ror16, ror8. Fix adds validation of this parameter -