* In all cases the location must not have been unmounted and the
* chosen mountpoint must be allowed to be mounted on. For "beneath"
* case we also require the location to be at the root of a mount
- * that has a parent (i.e. is not a root of some namespace).
+ * that has something mounted on top of it (i.e. has an overmount).
*/
static void do_lock_mount(const struct path *path,
struct pinned_mountpoint *res,
* @mnt_to: mount under which to mount
* @mp: mountpoint of @mnt_to
*
- * - Make sure that nothing can be mounted beneath the caller's current
- * root or the rootfs of the namespace.
* - Make sure that the caller can unmount the topmost mount ensuring
* that the caller could reveal the underlying mountpoint.
* - Ensure that nothing has been mounted on top of @mnt_from before we
*/
static int can_move_mount_beneath(const struct mount *mnt_from,
const struct mount *mnt_to,
- const struct mountpoint *mp)
+ struct pinned_mountpoint *mp)
{
struct mount *parent_mnt_to = mnt_to->mnt_parent;
if (mnt_from->overmount)
return -EINVAL;
- /*
- * Mounting beneath the rootfs only makes sense when the
- * semantics of pivot_root(".", ".") are used.
- */
- if (&mnt_to->mnt == current->fs->root.mnt)
- return -EINVAL;
- if (parent_mnt_to == current->nsproxy->mnt_ns->root)
- return -EINVAL;
-
if (mount_is_ancestor(mnt_to, mnt_from))
return -EINVAL;
* propagating a copy @c of @mnt_from on top of @mnt_to. This
* defeats the whole purpose of mounting beneath another mount.
*/
- if (propagation_would_overmount(parent_mnt_to, mnt_to, mp))
+ if (propagation_would_overmount(parent_mnt_to, mnt_to, mp->mp))
return -EINVAL;
/*
* @mnt_from beneath @mnt_to.
*/
if (check_mnt(mnt_from) &&
- propagation_would_overmount(parent_mnt_to, mnt_from, mp))
+ propagation_would_overmount(parent_mnt_to, mnt_from, mp->mp))
return -EINVAL;
return 0;
if (mp.parent != over->mnt_parent)
over = mp.parent->overmount;
- err = can_move_mount_beneath(old, over, mp.mp);
+ err = can_move_mount_beneath(old, over, &mp);
if (err)
return err;
}