From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>,
Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 v4 2/3] ve: give the pseudosuper relaxations of ve0 to its own tasks only
Date: Mon, 23 Nov 2026 10:19:12 +0100 [thread overview]
Message-ID: <5c4f9a90-231b-40d5-8370-26d69a040a62@virtuozzo.com> (raw)
In-Reply-To: <20261120-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v4-2-ac581cf6e36d@virtuozzo.com>
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@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.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-23 9:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 16:34 [Devel] [PATCH hci-8.2 v4 0/3] ve: Container start on the 26.3 kernel with libvzctl before 10.0.144 Konstantin Khorenko
2026-11-20 16:34 ` [Devel] [PATCH hci-8.2 v4 1/3] ve: trust every host task of a pseudosuper VE until it execs Konstantin Khorenko
2026-11-20 16:34 ` [Devel] [PATCH hci-8.2 v4 2/3] ve: give the pseudosuper relaxations of ve0 to its own tasks only Konstantin Khorenko
2026-11-23 9:19 ` Pavel Tikhomirov [this message]
2026-11-24 10:02 ` Mirian Shilakadze
2026-11-20 16:34 ` [Devel] [PATCH hci-8.2 v4 3/3] selftests/ve: check a host task entering a pseudosuper VE reaches its init Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c4f9a90-231b-40d5-8370-26d69a040a62@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
--cc=mirian.shilakadze@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.