milos-linux/fs/kernfs
Sebastian Andrzej Siewior 9aab10a024 kernfs: Don't re-lock kernfs_root::kernfs_rwsem in kernfs_fop_readdir().
The readdir operation iterates over all entries and invokes dir_emit()
for every entry passing kernfs_node::name as argument.
Since the name argument can change, and become invalid, the
kernfs_root::kernfs_rwsem lock should not be dropped to prevent renames
during the operation.

The lock drop around dir_emit() has been initially introduced in commit
   1e5289c97b ("sysfs: Cache the last sysfs_dirent to improve readdir scalability v2")

to avoid holding a global lock during a page fault. The lock drop is
wrong since the support of renames and not a big burden since the lock
is no longer global.

Don't re-acquire kernfs_root::kernfs_rwsem while copying the name to the
userpace buffer.

Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20250213145023.2820193-5-bigeasy@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-02-15 17:46:32 +01:00
..
dir.c kernfs: Don't re-lock kernfs_root::kernfs_rwsem in kernfs_fop_readdir(). 2025-02-15 17:46:32 +01:00
file.c kernfs: Acquire kernfs_rwsem in kernfs_notify_workfn(). 2025-02-15 17:46:32 +01:00
inode.c vfs-6.7.ctime 2023-10-30 09:47:13 -10:00
Kconfig
kernfs-internal.h kernfs: RCU protect kernfs_nodes and avoid kernfs_idr_lock in kernfs_find_and_get_node_by_id() 2024-01-30 15:54:25 -08:00
Makefile
mount.c kernfs: Acquire kernfs_rwsem in kernfs_node_dentry(). 2025-02-15 17:46:32 +01:00
symlink.c kernfs: fix all kernel-doc warnings and multiple typos 2022-11-23 19:28:26 +01:00