While a VE is pseudosuper, any task in it may write the read-only files
of the container's root cgroup and sees the hidden cgroup roots. That
includes the container's own binaries that vzctl and CRIU run during
start or restore. quotaon at start can rewrite the root memory.max, and
any of them can write 0 to ve.pseudosuper, which ends the window early
and makes CRIU's restoring tasks reachable again.

Use ve_current_is_pseudosuper() for both, so only setup tasks get them.

Feature: ve: CRIU support
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <[email protected]>
---
 kernel/cgroup/cgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 77903a56b79e..b0f2e7a24b5f 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4765,7 +4765,7 @@ static ssize_t cgroup_file_write(struct kernfs_open_file 
*of, char *buf,
 
        if (!ve_is_super(get_exec_env())
            && test_bit(CGRP_VE_ROOT, &cgrp->flags)
-           && !get_exec_env()->is_pseudosuper
+           && !ve_current_is_pseudosuper(get_exec_env())
            && !(cft->flags & CFTYPE_VE_WRITABLE))
                return -EPERM;
 
@@ -6947,7 +6947,7 @@ int ve_hide_cgroups(struct cgroup_root *root)
         * Hide ve cgroup in CT for docker, still showing it to pseudosuper
         * (criu), and also hide non-virtualized cgroups.
         */
-       return !ve_is_super(ve) && !ve->is_pseudosuper &&
+       return !ve_is_super(ve) && !ve_current_is_pseudosuper(ve) &&
               ((root->subsys_mask & hidden_mask) ||
                !is_virtualized_cgroot(root));
 }
-- 
2.43.0

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

Reply via email to