Re: [PATCH 1/3] ida: Introduce ida_weight()

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

 




On 02.11.2023 18:46, Matthew Wilcox wrote:
> On Thu, Nov 02, 2023 at 04:34:53PM +0100, Michal Wajdeczko wrote:
>> Add helper function that will calculate number of allocated IDs
>> in the IDA.  This might be helpful both for drivers to estimate
>> saturation of used IDs and for testing the IDA implementation.
> 
> Since you take & release the lock, the value is already somewhat racy.
> So why use the lock at all?  Wouldn't the RCU read lock be a better
> approach?

Actually I'm not so sure that RCU read lock would be sufficient right
now as we might hit UAF while checking bitmap_weight() as that bitmap
could be released in ida_free() before its pointer will be replaced:

	bitmap = xas_load(&xas);

	if (xa_is_value(bitmap)) {
...
	} else {
...
		if (bitmap_empty(bitmap->bitmap, IDA_BITMAP_BITS)) {
			kfree(bitmap);
delete:
			xas_store(&xas, NULL);
		}




[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