[RFC PATCH v8 08/29] mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS

Jarkko Sakkinen jarkko at kernel.org
Sun Nov 29 01:00:20 UTC 2026


On Sun, Nov 29, 2026 at 12:28:09AM +0000, sashiko-bot at kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] mount: missing CL_LOCK_SOURCE in do_move_mount() cross-userns
>   clone

I.e., should be:

diff --git a/fs/namespace.c b/fs/namespace.c
index 3308dbbe239a..7aae29833bff 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3852,9 +3852,11 @@ static int do_move_mount(const struct path *old_path,
                            (old->mnt.mnt_sb->s_flags & SB_NOUSER))
                                return -EINVAL;
                        src_user_ns = old->mnt_ns->user_ns;
-                       copy_flags = (target_mnt_ns->user_ns != src_user_ns) ?
-                                    (CL_SLAVE | CL_COPY_UNBINDABLE) :
-                                    CL_COPY_MNT_NS_FILE;
+                       if (!in_userns(target_mnt_ns->user_ns, src_user_ns))
+                               copy_flags = CL_SLAVE | CL_COPY_UNBINDABLE |
+                                            CL_LOCK_SOURCE;
+                       else
+                               copy_flags = CL_COPY_MNT_NS_FILE;
                        cloned = __do_loopback(old_path, true, copy_flags);
                        if (IS_ERR(cloned))
                                return PTR_ERR(cloned);

Br, Jarkko



More information about the Linux-security-module-archive mailing list