Re: [PATCH] Xarray: Fix race in xa_get_order()

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

 



On Sat, Mar 02, 2024 at 10:13:28PM +0800, Han Xing Yi wrote:
> Hello! This is my first patch ever, so please bear with me if I make some rookie
> mistakes. I've tried my best to follow the documentation :) 

Thanks!  This is indeed a mistake.  Probably a harmless one, but worth
fixing to silence the warning.

Annoyingly, building with C=1 (sparse) finds the problem:

  CHECK   ../lib/xarray.c
../lib/xarray.c:1779:54: warning: incorrect type in argument 1 (different address spaces)
../lib/xarray.c:1779:54:    expected void const *entry
../lib/xarray.c:1779:54:    got void [noderef] __rcu *

so that means I got out of the habit of running sparse, and for some
reason none of the build bots notified me of the new warning (or I
missed that email).

> +++ b/lib/xarray.c
> @@ -1776,7 +1776,7 @@ int xa_get_order(struct xarray *xa, unsigned long index)
>  
>  		if (slot >= XA_CHUNK_SIZE)
>  			break;
> -		if (!xa_is_sibling(xas.xa_node->slots[slot]))
> +		if (!xa_is_sibling(rcu_dereference(xas.xa_node->slots[slot])))

This is such a common thing to do that I have a helper for it.
So what I'll actually commit is:

-               if (!xa_is_sibling(xas.xa_node->slots[slot]))
+               if (!xa_is_sibling(xa_entry(xas.xa, xas.xa_node, slot)))

but I'll leave your name on it since you did the actual work.




[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