From: Christian Brauner <brauner@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: more breakage there (was Re: [RFC] move_mount(2): still breakage around new mount detection)
Date: Fri, 9 May 2025 13:06:25 +0200 [thread overview]
Message-ID: <20250509-nimmst-magerquark-21b49ee0438d@brauner> (raw)
In-Reply-To: <20250508055610.GB2023217@ZenIV>
On Thu, May 08, 2025 at 06:56:10AM +0100, Al Viro wrote:
> On Mon, Apr 28, 2025 at 07:53:18PM +0100, Al Viro wrote:
>
> > Up to you; propagation calculations *are* hard-serialized (on namespace_sem)
> > and changing that is too much pain to consider, so I have no problem with
> > globals in that specific case (note several such in propagate_mnt()
> > machinery; that was a deliberate decision to avoid shitloads of arguments
> > that would have to be passed around otherwise), but...
>
> OK, now I finally understand what felt fishy about either solution.
>
> Back when the checks had been IS_MNT_NEW, we were guaranteed that
> anything on the the slave lists of new mount would be new as well.
>
> No amount of copy_tree() could change ->mnt_master of existing mounts,
> so anything predating the beginning of propagate_mnt() would still
> have ->mnt_master pointing to old mounts - no operations other than
> copy_tree() had been done since we have taken namespace_sem.
Yes.
>
> That's where your IS_MNT_PROPAGATED breaks. It mixes "nothing useful
> to be found in this direction" with "don't mount anything on this one".
> And these are not the same now.
>
> Suppose you have mounts A, B and C, A propagating to B, B - to C.
>
> If you made B private, propagation would go directly from A to C,
> and mount on A/foo would result in a copy on C/foo.
>
> Suppose you've done open_tree B with OPEN_TREE_CLONE before making
> B private. After open_tree your propagation graph is
> A -> [B <-> B'] -> C
> with new mount B' being in your anon_ns. Making B private leaves you
> with
I cannot describe how much I hate mount propagation and how much I would
like to burn it from the face of this earth.
> A -> B' -> C
> and mount on A/foo still propagates to C/foo, along with foo in your
> anon_ns.
>
> So far, so good, but what happens if you move_mount the root of your
> anon_ns to A/foo? Sure, you want to suppress copying it to foo in B',
> but you will end suppressing the copy on C/foo as well. propagation_next()
> will not visit C at all - when it reaches B', it'll see IS_MNT_PROPAGATED
> and refuse to look what B' might be propagating to.
I regret that I reenabled propagation into anonymous mount namepaces in
the first place.
>
> IOW, IS_MNT_PROPAGATED in propagate_one() is fine, but in propagation_next(),
> skip_propagation_subtree() and next_group() we really need IS_MNT_NEW.
> And the check in propagate_one() should be
>
> /* skip ones added by this propagate_mnt() */
> if (IS_MNT_NEW(m))
> return 0;
> /* skip if mountpoint is outside of subtree seen 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)
> return 0;
> That part of check is really about the validity of this particular
> location, not the cutoff for further propagation. IS_MNT_NEW(),
> OTOH, is a hard cutoff.
>
> FWIW, I would take the last remaining IS_MNT_PROPAGATED() (in
> propagation_would_overmount()) as discussed in this thread -
> with
> - if (propagation_would_overmount(parent_mnt_to, mnt_from, mp))
> + if (check_mnt(mnt_from) &&
> + propagation_would_overmount(parent_mnt_to, mnt_from, mp))
> in can_move_mount_beneath() and lose the one in propagation_would_overmount()
Yes.
>
> I'll cook something along those lines (on top of "do_move_mount(): don't
> leak MNTNS_PROPAGATING on failures") and if it survives overnight tests
> post it tomorrow^Win the morning...
Thanks!
prev parent reply other threads:[~2025-05-09 11:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 6:30 [RFC] move_mount(2): still breakage around new mount detection Al Viro
2025-04-28 7:03 ` Al Viro
2025-04-28 8:50 ` Christian Brauner
2025-04-28 18:53 ` Al Viro
2025-04-29 4:03 ` Al Viro
2025-04-29 5:10 ` Al Viro
2025-04-29 5:27 ` Al Viro
2025-04-29 8:21 ` Christian Brauner
2025-05-05 5:08 ` Al Viro
2025-05-05 14:20 ` Christian Brauner
2025-04-29 7:56 ` Christian Brauner
2025-04-29 12:27 ` Al Viro
2025-04-29 7:52 ` Christian Brauner
2025-05-08 5:56 ` more breakage there (was Re: [RFC] move_mount(2): still breakage around new mount detection) Al Viro
2025-05-08 19:59 ` Al Viro
2025-05-08 20:00 ` [PATCH 1/4] __legitimize_mnt(): check for MNT_SYNC_UMOUNT should be under mount_lock Al Viro
2025-05-09 11:02 ` Christian Brauner
2025-05-08 20:01 ` [PATCH 2/4] do_umount(): add missing barrier before refcount checks in sync case Al Viro
2025-05-09 11:02 ` Christian Brauner
2025-05-08 20:02 ` [PATCH 3/4] do_move_mount(): don't leak MNTNS_PROPAGATING on failures Al Viro
2025-05-08 20:03 ` reproducer for "do_move_mount(): don't leak MNTNS_PROPAGATING on failures" Al Viro
2025-05-09 11:02 ` [PATCH 3/4] do_move_mount(): don't leak MNTNS_PROPAGATING on failures Christian Brauner
2025-05-13 11:03 ` Lai, Yi
2025-05-13 12:08 ` Al Viro
2025-05-13 14:33 ` Lai, Yi
2025-05-08 20:02 ` [PATCH 4/4] fix IS_MNT_PROPAGATING uses Al Viro
2025-05-08 20:04 ` reproducer for "fix IS_MNT_PROPAGATING uses" Al Viro
2025-05-09 11:01 ` [PATCH 4/4] fix IS_MNT_PROPAGATING uses Christian Brauner
2025-05-09 11:06 ` Christian Brauner [this message]
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=20250509-nimmst-magerquark-21b49ee0438d@brauner \
--to=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--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).