Re: [PATCH 2/2] xarray: Fix race in xas_find_chunk()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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>




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux