[Devel] [PATCH hci-8.2 v5 2/3] ve: give the pseudosuper relaxations of ve0 to its own tasks only
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Nov 27 20:39:44 MSK 2026
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 at virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Reviewed-by: Mirian Shilakadze <mirian.shilakadze at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at 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
More information about the Devel
mailing list