Skip to content

Commit 3b5260d

Browse files
author
Al Viro
committed
Don't propagate mounts into detached trees
All versions up to 6.14 did not propagate mount events into detached tree. Shortly after 6.14 a merge of vfs-6.15-rc1.mount.namespace (130e696) has changed that. Unfortunately, that has caused userland regressions (reported in https://lore.kernel.org/all/CAOYeF9WQhFDe+BGW=Dp5fK8oRy5AgZ6zokVyTj1Wp4EUiYgt4w@mail.gmail.com/) Straight revert wouldn't be an option - in particular, the variant in 6.14 had a bug that got fixed in d1ddc6f ("fix IS_MNT_PROPAGATING uses") and we don't want to bring the bug back. This is a modification of manual revert posted by Christian, with changes needed to avoid reintroducing the breakage in scenario described in d1ddc6f. Cc: [email protected] Reported-by: Allison Karlitskaya <[email protected]> Tested-by: Allison Karlitskaya <[email protected]> Acked-by: Christian Brauner <[email protected]> Co-developed-by: Christian Brauner <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent d1ddc6f commit 3b5260d

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
@@ -3648,24 +3648,15 @@ static int do_move_mount(struct path *old_path,
36483648
if (!(attached ? check_mnt(old) : is_anon_ns(ns)))
36493649
goto out;
36503650

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