]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
clone_mnt(): simplify the propagation-related logics
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 7 May 2025 18:05:50 +0000 (14:05 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 29 Jun 2025 22:13:41 +0000 (18:13 -0400)
commit49acacdc7cd3c1dcf5190a80ea9e6ca2ffa06cec
tree26537c40831906ea8368f1addcafafd838e025f1
parentd08fa7f44ae7f5ad5c842e15f2412790736a6144
clone_mnt(): simplify the propagation-related logics

The underlying rules are simple:
* MNT_SHARED should be set iff ->mnt_group_id of new mount ends up
non-zero.
* mounts should be on the same ->mnt_share cyclic list iff they have
the same non-zero ->mnt_group_id value.
* CL_PRIVATE is mutually exclusive with MNT_SHARED, MNT_SLAVE,
MNT_SHARED_TO_SLAVE and MNT_EXPIRE; the whole point of that thing is to
get a clone of old mount that would *not* be on any namespace-related
lists.

The above allows to make the logics more straightforward; what's more,
it makes the proof that invariants are maintained much simpler.
The variant in mainline is safe (aside of a very narrow race with
unsafe modification of mnt_flags right after we had the mount exposed
in superblock's ->s_mounts; theoretically it can race with ro remount
of the original, but it's not easy to hit), but proof of its correctness
is really unpleasant.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c