On Wed, Oct 11, 2023 at 05:02:32PM +0200, Jan Kara wrote: > xas_find_chunk() can be called only under RCU protection and thus tags > can be changing while it is working. Hence the code: > > unsigned long data = *addr & (~0UL << offset); > if (data) > return __ffs(data); > > is prone to 'data' being refetched from addr by the compiler and thus > calling __ffs() with 0 argument and undefined results. > > Fix the problem by removing XA_CHUNK_SIZE == BITS_PER_LONG special case > completely. find_next_bit() gets this right and there's no performance > difference because it is inline and has the very same special branch for > const-sized bitmaps anyway. > > Reported-by: Mirsad Todorovac <mirsad.todorovac@xxxxxxxxxxxx> > CC: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Signed-off-by: Jan Kara <jack@xxxxxxx> Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>