lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <874n7e4k78.fsf@xmission.com>
Date:	Thu, 14 Nov 2013 15:50:19 -0800
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Gao feng <gaofeng@...fujitsu.com>
Cc:	containers@...ts.linux-foundation.org,
	linux-fsdevel@...r.kernel.org, serge@...lyn.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] userns: allow privileged user to operate locked mount

Gao feng <gaofeng@...fujitsu.com> writes:

> Privileged user should have rights to mount/umount/move
> these even locked mount.

Hmm. This is pretty much a can't happen case, as the only exist in mount
namespaces where the global root isn't the root.  How are you getting
into this situation?  Using setns() ?

Why would we even care?

As implemented this patch does not handle nested user namespaces and
that really worries me at a semantic level.

We don't want to design cases where we can create containers in
containers.

Eric


> Signed-off-by: Gao feng <gaofeng@...fujitsu.com>
> ---
>  fs/namespace.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index da5c494..7097fc7 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1297,6 +1297,11 @@ static inline bool may_mount(void)
>  	return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
>  }
>  
> +static inline bool may_mount_lock(struct mount *mnt)
> +{
> +	return !(mnt->mnt.mnt_flags & MNT_LOCKED) || capable(CAP_SYS_ADMIN);
> +}
> +
>  /*
>   * Now umount can handle mount points as well as block devices.
>   * This is important for filesystems which use unnamed block devices.
> @@ -1330,7 +1335,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
>  		goto dput_and_out;
>  	if (!check_mnt(mnt))
>  		goto dput_and_out;
> -	if (mnt->mnt.mnt_flags & MNT_LOCKED)
> +	if (!may_mount_lock(mnt))
>  		goto dput_and_out;
>  
>  	retval = do_umount(mnt, flags);
> @@ -1768,7 +1773,8 @@ static int do_loopback(struct path *path, const char *old_name,
>  	if (!check_mnt(parent) || !check_mnt(old))
>  		goto out2;
>  
> -	if (!recurse && has_locked_children(old, old_path.dentry))
> +	if (!recurse && has_locked_children(old, old_path.dentry) &&
> +	    !capable(CAP_SYS_ADMIN))
>  		goto out2;
>  
>  	if (recurse)
> @@ -1895,7 +1901,7 @@ static int do_move_mount(struct path *path, const char *old_name)
>  	if (!check_mnt(p) || !check_mnt(old))
>  		goto out1;
>  
> -	if (old->mnt.mnt_flags & MNT_LOCKED)
> +	if (!may_mount_lock(old))
>  		goto out1;
>  
>  	err = -EINVAL;
> @@ -2679,7 +2685,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
>  		goto out4;
>  	if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
>  		goto out4;
> -	if (new_mnt->mnt.mnt_flags & MNT_LOCKED)
> +	if (!may_mount_lock(new_mnt))
>  		goto out4;
>  	error = -ENOENT;
>  	if (d_unlinked(new.dentry))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ