Skip to content

Commit ce7df19

Browse files
author
Al Viro
committed
attach_recursive_mnt(): do not lock the covering tree when sliding something under it
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: 3bd045c ("separate copying and locking mount tree on cross-userns copies") Signed-off-by: Al Viro <[email protected]>
1 parent 7484e15 commit ce7df19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/namespace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,14 +2768,14 @@ static int attach_recursive_mnt(struct mount *source_mnt,
27682768
hlist_for_each_entry_safe(child, n, &tree_list, mnt_hash) {
27692769
struct mount *q;
27702770
hlist_del_init(&child->mnt_hash);
2771-
q = __lookup_mnt(&child->mnt_parent->mnt,
2772-
child->mnt_mountpoint);
2773-
if (q)
2774-
mnt_change_mountpoint(child, smp, q);
27752771
/* Notice when we are propagating across user namespaces */
27762772
if (child->mnt_parent->mnt_ns->user_ns != user_ns)
27772773
lock_mnt_tree(child);
27782774
child->mnt.mnt_flags &= ~MNT_LOCKED;
2775+
q = __lookup_mnt(&child->mnt_parent->mnt,
2776+
child->mnt_mountpoint);
2777+
if (q)
2778+
mnt_change_mountpoint(child, smp, q);
27792779
commit_tree(child);
27802780
}
27812781
put_mountpoint(smp);

0 commit comments

Comments
 (0)