]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
check_for_nsfs_mounts(): no need to take locks
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Aug 2025 00:28:35 +0000 (20:28 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:35:57 +0000 (19:35 -0400)
commit6b448d7a7c4848fd6cbe0eee49834df7d25b25f8
tree7d8e60f6b968573fe50ff96f2456020f224b0a93
parent747e91e5b7396eba699989072c61e8fb076bbea4
check_for_nsfs_mounts(): no need to take locks

Currently we are taking mount_writer; what that function needs is
either mount_locked_reader (we are not changing anything, we just
want to iterate through the subtree) or namespace_shared and
a reference held by caller on the root of subtree - that's also
enough to stabilize the topology.

The thing is, all callers are already holding at least namespace_shared
as well as a reference to the root of subtree.

Let's make the callers provide locking warranties - don't mess with
mount_lock in check_for_nsfs_mounts() itself and document the locking
requirements.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c