From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>,
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v5 2/3] ve: give the pseudosuper relaxations of ve0 to its own tasks only
Date: Fri, 27 Nov 2026 18:39:44 +0100 [thread overview]
Message-ID: <20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-2-32c4b6342ec2@virtuozzo.com> (raw)
In-Reply-To: <20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-0-32c4b6342ec2@virtuozzo.com>
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.
Grant nothing to a task outside the VE asked about, and in ve0 grant
to every task of it. 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
Suggested-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
kernel/ve/ve.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 0ad145b38b54b..bcdac9c846a1c 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1784,19 +1784,23 @@ 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))
+ if (task_ve(current) != ve)
+ return false;
+
+ if (ve_is_super(get_exec_env()))
return true;
- return ve->is_pseudosuper && task_ve(current) == ve && mm &&
+ return ve->is_pseudosuper && mm &&
(mm->vps_dumpable == VD_VE_SETUP_TASK ||
mm->vps_dumpable == VD_VE_ENTER_TASK);
}
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-27 17:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 17:39 [Devel] [PATCH hci-8.2 v5 0/3] ve: Container start on the 26.3 kernel with libvzctl before 10.0.144 Konstantin Khorenko
2026-11-27 17:39 ` [Devel] [PATCH hci-8.2 v5 1/3] ve: trust every host task of a pseudosuper VE until it execs Konstantin Khorenko
2026-12-01 0:52 ` no-reply
2026-11-27 17:39 ` Konstantin Khorenko [this message]
2026-12-01 0:55 ` [Devel] [PATCH hci-8.2 v5 2/3] ve: give the pseudosuper relaxations of ve0 to its own tasks only no-reply
2026-11-27 17:39 ` [Devel] [PATCH hci-8.2 v5 3/3] selftests/ve: check a host task entering a pseudosuper VE reaches its init Konstantin Khorenko
2026-12-01 1:02 ` no-reply
2026-11-27 17:43 ` [Devel] [PATCH hci-8.2 v5 0/3] ve: Container start on the 26.3 kernel with libvzctl before 10.0.144 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=20261127-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v5-2-32c4b6342ec2@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=mirian.shilakadze@virtuozzo.com \
--cc=ptikhomirov@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox