Re: [PATCH] libbpf hashmap: Fix undefined behavior in hash_bits

2020-10-29 Thread Andrii Nakryiko
On Thu, Oct 29, 2020 at 9:11 AM Ian Rogers wrote: > > If bits is 0, the case when the map is empty, then the >> is the size of > the register which is undefined behavior - on x86 it is the same as a > shift by 0. Fix by handling the 0 case explicitly when running with > address sanitizer. > > A va

Re: [PATCH] libbpf hashmap: Fix undefined behavior in hash_bits

2020-10-29 Thread Song Liu
> On Oct 29, 2020, at 9:09 AM, Ian Rogers wrote: > > If bits is 0, the case when the map is empty, then the >> is the size of > the register which is undefined behavior - on x86 it is the same as a > shift by 0. Fix by handling the 0 case explicitly when running with > address sanitizer. > >

Re: [PATCH] libbpf hashmap: fix undefined behavior in hash_bits

2020-05-08 Thread Andrii Nakryiko
On Fri, May 8, 2020 at 12:21 AM Ian Rogers wrote: > > On Fri, May 8, 2020 at 12:12 AM Andrii Nakryiko > wrote: > > > > On Thu, May 7, 2020 at 11:40 PM Ian Rogers wrote: > > > > > > If bits is 0, the case when the map is empty, then the >> is the size of > > > the register which is undefined beha

Re: [PATCH] libbpf hashmap: fix undefined behavior in hash_bits

2020-05-08 Thread Andrii Nakryiko
On Thu, May 7, 2020 at 11:40 PM Ian Rogers wrote: > > If bits is 0, the case when the map is empty, then the >> is the size of > the register which is undefined behavior - on x86 it is the same as a > shift by 0. Fix by handling the 0 case explicitly. > > Signed-off-by: Ian Rogers > --- No need.