[Devel] [PATCH hci-8.2 v4 2/3] ve: give the pseudosuper relaxations of ve0 to its own tasks only

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Nov 23 12:19:12 MSK 2026



On 11/20/26 17:34, Konstantin Khorenko wrote:
> ve_current_is_pseudosuper() answers yes whenever the VE it is asked
> about is ve0, whoever asks. The line keeps the behaviour of ve0 being
> statically pseudosuper, but it reads as a grant to any task: a
> container task would get the relaxations of the host from a caller
> that passes it ve0.
> 
> Let the ve0 branch ask whether current is a ve0 task instead. The
> relaxations of a VE belong to the tasks the host sent into it, and for
> ve0 those are its own tasks, no mark involved.
> 
> No caller but one sees a different answer:
> 
> - devcgroup_legacy_check_permission(), netlink_setsockopt() for
>   NETLINK_REPAIR, cgroup_file_write(), ve_hide_cgroups(),
>   prctl_set_task_ct_fields(), ve_devmnt_verify() and
>   ve_devmnt_process() pass the caller's own VE behind a !ve_is_super()
>   check;
> - ve_features_write(), ve_failcount_write(),
>   ve_pid_max_write_running_u64() and ve_aio_max_nr_write() pass the css
>   of a CFTYPE_NOT_ON_ROOT file, which ve0 does not have;
> - task_still_dumpable() asks only about a VD_VE_SETUP_TASK of a VE
>   other than ve0, ve_vps_dumpable() reports ve0's as
>   VD_PTRACE_COREDUMP.
> 
> ve_try_reserve_mount() does pass ve0 for a VE task: a host helper that
> joined the VE cgroup but still sits in the host's mount namespace owns
> its bind mounts through ve0. Its reservation now goes through ve0's
> mnt_avail_nr like any counted one; the counter starts at INT_MAX and
> has no cgroup file to lower it, so the mount is granted as before.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-156164
> 
> Feature: trace: prohibit tracing sensitive tasks from CT
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
> ---
>  kernel/ve/ve.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
> index 0ad145b38b54b..7bbc1106ba389 100644
> --- a/kernel/ve/ve.c
> +++ b/kernel/ve/ve.c
> @@ -1784,17 +1784,18 @@ bool ve_check_trusted_exec(struct file *file, struct filename *name)
>   * ve_current_is_pseudosuper - may current use the pseudosuper relaxations of @ve
>   * @ve: the VE that grants them
>   *
> - * Always true for ve0. Otherwise only a host task of @ve may, one the host
> - * sent in while @ve was starting (VD_VE_SETUP_TASK) or after that
> - * (VD_VE_ENTER_TASK), and only until pseudosuper is cleared. Exec clears
> - * both marks, so the container binaries that the host tools run may not.
> + * The relaxations of ve0 belong to its own tasks. Those of a container
> + * belong to a host task of @ve, one the host sent in while @ve was starting
> + * (VD_VE_SETUP_TASK) or after that (VD_VE_ENTER_TASK), and only until
> + * pseudosuper is cleared. Exec clears both marks, so the container binaries
> + * that the host tools run may not.
>   */
>  bool ve_current_is_pseudosuper(struct ve_struct *ve)
>  {
>  	struct mm_struct *mm = current->mm;
>  
>  	if (ve_is_super(ve))
> -		return true;
> +		return ve_is_super(get_exec_env());
>  
>  	return ve->is_pseudosuper && task_ve(current) == ve && mm &&
>  	       (mm->vps_dumpable == VD_VE_SETUP_TASK ||

I'd rather you simplify:

bool ve_current_is_pseudosuper(struct ve_struct *ve)
{
        struct mm_struct *mm = current->mm;

        if (task_ve(current) != ve)
                return false;

        /* ve0 trusts all of its own tasks */
        if (ve_is_super(get_exec_env()))
                return true;

        return ve->is_pseudosuper && mm &&
               (mm->vps_dumpable == VD_VE_SETUP_TASK ||
                mm->vps_dumpable == VD_VE_ENTER_TASK);
}

So it's absolutely obvious that we check super only against task's own ve.

> 

-- 
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.



More information about the Devel mailing list