]> www.infradead.org Git - nvme.git/commitdiff
fs: actually hold the namespace semaphore
authorChristian Brauner <brauner@kernel.org>
Thu, 3 Apr 2025 14:43:50 +0000 (16:43 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2025 22:45:35 +0000 (15:45 -0700)
Don't use a scoped guard that only protects the next statement.

Use a regular guard to make sure that the namespace semaphore is held
across the whole function.

Signed-off-by: Christian Brauner <brauner@kernel.org>
Reported-by: Leon Romanovsky <leon@kernel.org>
Link: https://lore.kernel.org/all/20250401170715.GA112019@unreal/
Fixes: db04662e2f4f ("fs: allow detached mounts in clone_private_mount()")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/namespace.c

index 16292ff760c93345e9db36c17981b062bd4b71f3..14935a0500a2068e08bb8a53787b1d6e404e474f 100644 (file)
@@ -2478,7 +2478,8 @@ struct vfsmount *clone_private_mount(const struct path *path)
        struct mount *old_mnt = real_mount(path->mnt);
        struct mount *new_mnt;
 
-       scoped_guard(rwsem_read, &namespace_sem)
+       guard(rwsem_read)(&namespace_sem);
+
        if (IS_MNT_UNBINDABLE(old_mnt))
                return ERR_PTR(-EINVAL);