ve_setup_task() marks a task entering a running VE VD_VE_ENTER_TASK,
which hides it from ptrace and /proc/<pid>/exe inside the VE. A
container task gets the mark too when it setns()es into its own VE or
enters a nested one, and a host task entering a stopping or stopped VE
is not hidden at all.

The mark says a task is the host's, a later change lets it skip the
mount limit of a pseudosuper VE, and it goes to the mm, which a
container task may share with others. So mark only tasks coming from
the host, in every VE state but starting, which the next change
handles. A task entering its nested VE is no longer hidden there. In a
pseudosuper VE the host's tasks cannot be told from the container's
yet, so a task leaving one is still marked until the next change.

Feature: trace: prohibit tracing sensitive tasks from CT
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <[email protected]>
---
 kernel/ve/ve.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 72a2834707c5..ff1c7f9b88c7 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1837,8 +1837,14 @@ void ve_setup_task(struct task_struct *task, struct 
ve_struct *old_ve,
        if (ve == &ve0)
                return;
 
-       /* this prohibits ptracing of task entered to VE from host system */
-       if (VE_IS_RUNNING(ve) && task->mm)
+       /*
+        * A task the host sends into a started VE is hidden from the tasks of
+        * the VE. The mark goes to the mm, which may be shared, so a task
+        * coming from a container never gets it, unless the container is
+        * pseudosuper: the host's tasks there cannot be told from its own.
+        */
+       if (task->mm && old_ve != ve && ve->state != VE_STATE_STARTING &&
+           (ve_is_super(old_ve) || old_ve->is_pseudosuper))
                task->mm->vps_dumpable = VD_VE_ENTER_TASK;
 
        /* Drop OOM protection. */
-- 
2.43.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to