linux/fs/cachefiles
Jingbo Xu 97cfd5e20d cachefiles: add missing lock protection when polling
[ Upstream commit cf5bb09e74 ]

Add missing lock protection in poll routine when iterating xarray,
otherwise:

Even with RCU read lock held, only the slot of the radix tree is
ensured to be pinned there, while the data structure (e.g. struct
cachefiles_req) stored in the slot has no such guarantee.  The poll
routine will iterate the radix tree and dereference cachefiles_req
accordingly.  Thus RCU read lock is not adequate in this case and
spinlock is needed here.

Fixes: b817e22b2e ("cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Link: https://lore.kernel.org/r/20240628062930.2467993-10-libaokun@huaweicloud.com
Acked-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-07-18 13:18:32 +02:00
..
cache.c cachefiles: fix memory leak in cachefiles_add_cache() 2024-03-01 13:26:32 +01:00
daemon.c cachefiles: add missing lock protection when polling 2024-07-18 13:18:32 +02:00
error_inject.c cachefiles: Add some error injection support 2022-01-07 13:40:56 +00:00
interface.c cachefiles: extract ondemand info field from cachefiles_object 2024-06-21 14:35:46 +02:00
internal.h cachefiles: cyclic allocation of msg_id to avoid reuse 2024-07-18 13:18:32 +02:00
io.c cachefiles: implement on-demand read 2022-05-18 00:11:18 +08:00
Kconfig cachefiles: notify the user daemon when looking up cookie 2022-05-18 00:11:17 +08:00
key.c cachefiles: Implement key to filename encoding 2022-01-07 13:42:16 +00:00
main.c cachefiles: Implement object lifecycle funcs 2022-01-07 13:42:08 +00:00
Makefile cachefiles: notify the user daemon when looking up cookie 2022-05-18 00:11:17 +08:00
namei.c mm, netfs, fscache: stop read optimisation when folio removed from pagecache 2024-01-10 17:10:31 +01:00
ondemand.c cachefiles: cyclic allocation of msg_id to avoid reuse 2024-07-18 13:18:32 +02:00
security.c cachefiles: Add security derivation 2022-01-07 13:41:14 +00:00
volume.c fscache, cachefiles: Store the volume coherency data 2022-01-07 13:43:03 +00:00
xattr.c cachefiles: propagate errors from vfs_getxattr() to avoid infinite loop 2024-07-18 13:18:31 +02:00