Commit a82ba839 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 724b03ee 3b5260d1
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -7,10 +7,6 @@

extern struct list_head notify_list;

typedef __u32 __bitwise mntns_flags_t;

#define MNTNS_PROPAGATING	((__force mntns_flags_t)(1 << 0))

struct mnt_namespace {
	struct ns_common	ns;
	struct mount *	root;
@@ -37,7 +33,6 @@ struct mnt_namespace {
	struct rb_node		mnt_ns_tree_node; /* node in the mnt_ns_tree */
	struct list_head	mnt_ns_list; /* entry in the sequential list of mounts namespace */
	refcount_t		passive; /* number references not pinning @mounts */
	mntns_flags_t		mntns_flags;
} __randomize_layout;

struct mnt_pcp {
+2 −13
Original line number Diff line number Diff line
@@ -3649,7 +3649,7 @@ static int do_move_mount(struct path *old_path,
	if (!(attached ? check_mnt(old) : is_anon_ns(ns)))
		goto out;

	if (is_anon_ns(ns)) {
	if (is_anon_ns(ns) && ns == p->mnt_ns) {
		/*
		 * Ending up with two files referring to the root of the
		 * same anonymous mount namespace would cause an error
@@ -3657,16 +3657,7 @@ static int do_move_mount(struct path *old_path,
		 * twice into the mount tree which would be rejected
		 * later. But be explicit about it right here.
		 */
		if ((is_anon_ns(p->mnt_ns) && ns == p->mnt_ns))
		goto out;

		/*
		 * If this is an anonymous mount tree ensure that mount
		 * propagation can detect mounts that were just
		 * propagated to the target mount tree so we don't
		 * propagate onto them.
		 */
		ns->mntns_flags |= MNTNS_PROPAGATING;
	} else if (is_anon_ns(p->mnt_ns)) {
		/*
		 * Don't allow moving an attached mount tree to an
@@ -3723,8 +3714,6 @@ static int do_move_mount(struct path *old_path,
	if (attached)
		put_mountpoint(old_mp);
out:
	if (is_anon_ns(ns))
		ns->mntns_flags &= ~MNTNS_PROPAGATING;
	unlock_mount(mp);
	if (!err) {
		if (attached) {
+2 −2
Original line number Diff line number Diff line
@@ -231,8 +231,8 @@ static int propagate_one(struct mount *m, struct mountpoint *dest_mp)
	/* skip if mountpoint isn't visible in m */
	if (!is_subdir(dest_mp->m_dentry, m->mnt.mnt_root))
		return 0;
	/* skip if m is in the anon_ns we are emptying */
	if (m->mnt_ns->mntns_flags & MNTNS_PROPAGATING)
	/* skip if m is in the anon_ns */
	if (is_anon_ns(m->mnt_ns))
		return 0;

	if (peers(m, last_dest)) {