[Devel] [PATCH RH7 3/3] vfs: allow mount proc and mqueue inside container
Pavel Tikhomirov
ptikhomirov at odin.com
Wed Jul 1 07:08:31 PDT 2015
It also allows to start container if CAP_SYS_ADMIN is unset with vzctl
else we get error:
vzctl set 206 --capability sys_admin:off --save
vzctl start 206
Starting Container ...
Unmount image: /vz/private/206/root.hdd
Unmounting file system at /vz/root/206
Unmounting device /dev/ploop28512
Container is unmounted
Mount image: /vz/private/206/root.hdd
Opening delta /vz/private/206/root.hdd/root.hds
Adding delta dev=/dev/ploop28512 img=/vz/private/206/root.hdd/root.hds (rw)
Mounting /dev/ploop28512p1 at /vz/root/206 fstype=ext4
data='balloon_ino=12,pfcache_csum,,'
Container is mounted
Os release: 3.10.0-123.1.2.vz7.5.23
Failed to mount /proc: Operation not permitted
Unmount image: /vz/private/206/root.hdd
Unmounting file system at /vz/root/206
Unmounting device /dev/ploop28512
Container is unmounted
Failed to start the Container
On 06/30/2015 03:17 PM, Pavel Tikhomirov wrote:
> need this for docker, as it tries to mount proc and mqueue
> and as we will not allow CAP_SYS_ADMIN in container.
>
> * after switching to user namespaces we won't need this patch
> https://jira.sw.ru/browse/PSBM-34523
>
> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> ---
> fs/proc/root.c | 3 ++-
> ipc/mqueue.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/root.c b/fs/proc/root.c
> index 88be7c2..0b7dbdb 100644
> --- a/fs/proc/root.c
> +++ b/fs/proc/root.c
> @@ -121,7 +121,8 @@ static struct dentry *proc_mount(struct file_system_type *fs_type,
> options = data;
>
> if (!current_user_ns()->may_mount_proc ||
> - !ns_capable(ns->user_ns, CAP_SYS_ADMIN))
> + (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) &&
> + !ns_capable(ns->user_ns, CAP_VE_SYS_ADMIN)))
> return ERR_PTR(-EPERM);
> }
>
> diff --git a/ipc/mqueue.c b/ipc/mqueue.c
> index 657814c..c5f1d3e 100644
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -335,7 +335,8 @@ static struct dentry *mqueue_mount(struct file_system_type *fs_type,
> /* Don't allow mounting unless the caller has CAP_SYS_ADMIN
> * over the ipc namespace.
> */
> - if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
> + if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) &&
> + !ns_capable(ns->user_ns, CAP_VE_SYS_ADMIN))
> return ERR_PTR(-EPERM);
>
> data = ns;
>
--
Best regards, Tikhomirov Pavel
Software Developer, Odin.
More information about the Devel
mailing list