[RFC PATCH v5 07/25] mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Sun Nov 22 00:10:56 UTC 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mount: missing SB_NOUSER check in do_move_mount() for
MOVE_MOUNT_CLONE
--
commit 0d056169d39e8a161d1951b83a6a28ab91fbc2ea
Author: Jarkko Sakkinen <jarkko at kernel.org>
mount: Support MOVE_MOUNT_CLONE with MOVE_MOUNT_T_MNTNS
This commit adds MOVE_MOUNT_CLONE for use with MOVE_MOUNT_T_MNTNS so
move_mount() can recursively loopback-clone a path from the caller's mount
namespace directly into a target mount namespace file descriptor.
> diff --git a/fs/namespace.c b/fs/namespace.c
> index b65f1fdd92811..1e7d776c09660 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
[ ... ]
> @@ -3835,6 +3833,35 @@ static int do_move_mount(const struct path *old_path,
> if (m == target_mnt_ns->root)
> return beneath ? -EINVAL : -EBUSY;
> }
> + if (flags & MNT_TREE_CLONE) {
> + unsigned int copy_flags;
> +
> + if (!check_mnt(old) || old->mnt_ns == target_mnt_ns)
> + 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;
> + cloned = __do_loopback(old_path, true, copy_flags);
> + if (IS_ERR(cloned))
> + return PTR_ERR(cloned);
> + old = cloned;
> + if (d_is_symlink(old->mnt.mnt_root)) {
> + err = -EINVAL;
> + goto out_cloned;
> + }
[Severity: Medium]
Does this allow cloning and attaching an SB_NOUSER mount such as the
caller's base nullfs mount?
do_loopback() pairs __do_loopback() with graft_tree(), which rejects
SB_NOUSER mounts, and the non-cloning check_mnt(old) branch below rejects
!mnt_has_parent(old). Here __do_loopback() is followed directly by
attach_recursive_mnt(). If old_path resolves to a mount namespace's base
nullfs mount (for example via an O_PATH fd or a pre-init root) and is
cloned onto "/" of an empty target_mnt_ns, a second nullfs mount is
attached on top of target_mnt_ns->root, causing mnt_ns_get_root() to treat
it as a live root filesystem and permanently blocking subsequent rootfs
installation on target_mnt_ns with -EBUSY.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121000844.1863324-1-jarkko@kernel.org?part=7
More information about the Linux-security-module-archive
mailing list