diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2025-06-22 18:03:29 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-07-06 10:58:00 +0200 |
| commit | d3615894f7073d65e3816826192a83ada29d7779 (patch) | |
| tree | b6013054b7f56773d6ba50c6d0664fed996dacf3 /fs | |
| parent | 6eb211788e1370af52a245d4d7da35c374c7b401 (diff) | |
| download | linux-d3615894f7073d65e3816826192a83ada29d7779.tar.gz linux-d3615894f7073d65e3816826192a83ada29d7779.tar.bz2 linux-d3615894f7073d65e3816826192a83ada29d7779.zip | |
attach_recursive_mnt(): do not lock the covering tree when sliding something under it
[ Upstream commit ce7df19686530920f2f6b636e71ce5eb1d9303ef ]
If we are propagating across the userns boundary, we need to lock the
mounts added there. However, in case when something has already
been mounted there and we end up sliding a new tree under that,
the stuff that had been there before should not get locked.
IOW, lock_mnt_tree() should be called before we reparent the
preexisting tree on top of what we are adding.
Fixes: 3bd045cc9c4b ("separate copying and locking mount tree on cross-userns copies")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/namespace.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index aae1a77ac2d3..67d89ebb5044 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2249,14 +2249,14 @@ static int attach_recursive_mnt(struct mount *source_mnt, hlist_for_each_entry_safe(child, n, &tree_list, mnt_hash) { struct mount *q; hlist_del_init(&child->mnt_hash); - q = __lookup_mnt(&child->mnt_parent->mnt, - child->mnt_mountpoint); - if (q) - mnt_change_mountpoint(child, smp, q); /* Notice when we are propagating across user namespaces */ if (child->mnt_parent->mnt_ns->user_ns != user_ns) lock_mnt_tree(child); child->mnt.mnt_flags &= ~MNT_LOCKED; + q = __lookup_mnt(&child->mnt_parent->mnt, + child->mnt_mountpoint); + if (q) + mnt_change_mountpoint(child, smp, q); commit_tree(child); } put_mountpoint(smp); |
