linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	 Miklos Szeredi <miklos@szeredi.hu>, Jan Kara <jack@suse.cz>,
	 Christian Brauner <brauner@kernel.org>,
	 Allison Karlitskaya <lis@redhat.com>
Subject: [PATCH 1/2] mount: fix detached mount regression
Date: Thu, 05 Jun 2025 14:50:53 +0200	[thread overview]
Message-ID: <20250605-work-mount-regression-v1-1-60c89f4f4cf5@kernel.org> (raw)
In-Reply-To: <20250605-work-mount-regression-v1-0-60c89f4f4cf5@kernel.org>

When we disabled mount propagation into detached trees again this
accidently broke mounting detached mount trees onto other detached mount
trees. The mount_setattr_tests selftests fail and Allison reported it as
well. Fix the regression.

Fixes: 3b5260d12b1f ("Don't propagate mounts into detached trees")
Reported-by: Allison Karlitskaya <lis@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/namespace.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 2f2e93927f46..cc08eab031db 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3634,22 +3634,22 @@ 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) && ns == p->mnt_ns) {
-		/*
-		 * Ending up with two files referring to the root of the
-		 * same anonymous mount namespace would cause an error
-		 * as this would mean trying to move the same mount
-		 * twice into the mount tree which would be rejected
-		 * later. But be explicit about it right here.
-		 */
+	/*
+	 * Ending up with two files referring to the root of the
+	 * same anonymous mount namespace would cause an error
+	 * as this would mean trying to move the same mount
+	 * twice into the mount tree which would be rejected
+	 * later. But be explicit about it right here.
+	 */
+	if (is_anon_ns(ns) && ns == p->mnt_ns)
 		goto out;
-	} else if (is_anon_ns(p->mnt_ns)) {
-		/*
-		 * Don't allow moving an attached mount tree to an
-		 * anonymous mount tree.
-		 */
+
+	/*
+	 * Don't allow moving an attached mount tree to an
+	 * anonymous mount tree.
+	 */
+	if (!is_anon_ns(ns) && is_anon_ns(p->mnt_ns))
 		goto out;
-	}
 
 	if (old->mnt.mnt_flags & MNT_LOCKED)
 		goto out;

-- 
2.47.2


  reply	other threads:[~2025-06-05 12:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 12:50 [PATCH 0/2] mount: fix detached mount regression Christian Brauner
2025-06-05 12:50 ` Christian Brauner [this message]
2025-06-06  4:54   ` [PATCH 1/2] " Al Viro
2025-06-06  5:14     ` Al Viro
2025-06-06  7:01       ` Al Viro
2025-06-06  7:58         ` Christian Brauner
2025-06-06 17:45           ` Al Viro
2025-06-07  5:20             ` Al Viro
2025-06-11  9:36               ` Christian Brauner
2025-06-11 17:29                 ` Al Viro
2025-06-12 12:16                   ` Christian Brauner
2025-06-05 12:50 ` [PATCH 2/2] selftests/mount_setattr: adapt detached mount propagation test Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250605-work-mount-regression-v1-1-60c89f4f4cf5@kernel.org \
    --to=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lis@redhat.com \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).