Skip to content

Commit

Permalink
fs: actually hold the namespace semaphore
Browse files Browse the repository at this point in the history
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: db04662 ("fs: allow detached mounts in clone_private_mount()")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christian Brauner authored and Linus Torvalds committed Apr 3, 2025
1 parent 56770e2 commit c0dbd11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c0dbd11

Please sign in to comment.