Skip to content

Commit a82ba83

Browse files
committed
Merge tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull mount propagation fix from Al Viro: "6.15 allowed mount propagation to destinations in detached trees; unfortunately, that breaks existing userland, so the old behaviour needs to be restored. It's not exactly a revert - the original behaviour had a bug, where existence of detached tree might disrupt propagation between locations not in detached trees. Thankfully, userland did not depend upon that bug, so we want to keep the fix" * tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Don't propagate mounts into detached trees
2 parents 724b03e + 3b5260d commit a82ba83

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

fs/mount.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
extern struct list_head notify_list;
99

10-
typedef __u32 __bitwise mntns_flags_t;
11-
12-
#define MNTNS_PROPAGATING ((__force mntns_flags_t)(1 << 0))
13-
1410
struct mnt_namespace {
1511
struct ns_common ns;
1612
struct mount * root;
@@ -37,7 +33,6 @@ struct mnt_namespace {
3733
struct rb_node mnt_ns_tree_node; /* node in the mnt_ns_tree */
3834
struct list_head mnt_ns_list; /* entry in the sequential list of mounts namespace */
3935
refcount_t passive; /* number references not pinning @mounts */
40-
mntns_flags_t mntns_flags;
4136
} __randomize_layout;
4237

4338
struct mnt_pcp {

fs/namespace.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,24 +3649,15 @@ static int do_move_mount(struct path *old_path,
36493649
if (!(attached ? check_mnt(old) : is_anon_ns(ns)))
36503650
goto out;
36513651

3652-
if (is_anon_ns(ns)) {
3652+
if (is_anon_ns(ns) && ns == p->mnt_ns) {
36533653
/*
36543654
* Ending up with two files referring to the root of the
36553655
* same anonymous mount namespace would cause an error
36563656
* as this would mean trying to move the same mount
36573657
* twice into the mount tree which would be rejected
36583658
* later. But be explicit about it right here.
36593659
*/
3660-
if ((is_anon_ns(p->mnt_ns) && ns == p->mnt_ns))
3661-
goto out;
3662-
3663-
/*
3664-
* If this is an anonymous mount tree ensure that mount
3665-
* propagation can detect mounts that were just
3666-
* propagated to the target mount tree so we don't
3667-
* propagate onto them.
3668-
*/
3669-
ns->mntns_flags |= MNTNS_PROPAGATING;
3660+
goto out;
36703661
} else if (is_anon_ns(p->mnt_ns)) {
36713662
/*
36723663
* Don't allow moving an attached mount tree to an
@@ -3723,8 +3714,6 @@ static int do_move_mount(struct path *old_path,
37233714
if (attached)
37243715
put_mountpoint(old_mp);
37253716
out:
3726-
if (is_anon_ns(ns))
3727-
ns->mntns_flags &= ~MNTNS_PROPAGATING;
37283717
unlock_mount(mp);
37293718
if (!err) {
37303719
if (attached) {

fs/pnode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ static int propagate_one(struct mount *m, struct mountpoint *dest_mp)
231231
/* skip if mountpoint isn't visible in m */
232232
if (!is_subdir(dest_mp->m_dentry, m->mnt.mnt_root))
233233
return 0;
234-
/* skip if m is in the anon_ns we are emptying */
235-
if (m->mnt_ns->mntns_flags & MNTNS_PROPAGATING)
234+
/* skip if m is in the anon_ns */
235+
if (is_anon_ns(m->mnt_ns))
236236
return 0;
237237

238238
if (peers(m, last_dest)) {

0 commit comments

Comments
 (0)