While a VE is pseudosuper, any task in it skips the device mount option
filter and the VE mount limit, including the container's own binaries
that vzctl and CRIU run.

Use ve_current_is_pseudosuper() instead. The mount limit also lets
through a host task that joined the VE after it started, such as the
CRIU helper that mounts proc for a nested pid namespace during restore.
Without that, restoring such a container near its mount limit fails.

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

diff --git a/fs/namespace.c b/fs/namespace.c
index d622d9b72d32..20a03419bc0c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3230,7 +3230,7 @@ int ve_devmnt_process(struct ve_struct *ve, dev_t dev, 
void **data_pp, int remou
                         * we don't check for allowed options filtering, since
                         * restore mode is special.
                         */
-                       if (ve->is_pseudosuper)
+                       if (ve_current_is_pseudosuper(ve))
                                err = 0;
 
                        if (!err && !remount)
@@ -3255,7 +3255,7 @@ int ve_devmnt_process(struct ve_struct *ve, dev_t dev, 
void **data_pp, int remou
                         * the way userspace tool restore container
                         * it might be nonempty as well.
                         */
-                       if (ve->is_pseudosuper) {
+                       if (ve_current_is_pseudosuper(ve)) {
                                err = 0;
                        } else if (((char *)*data_pp)[0] == '\0') {
                                err = 0;
@@ -3330,7 +3330,7 @@ int ve_devmnt_verify(struct ve_struct *ve, dev_t dev, 
char *opts, bool new_mount
        bool found = false;
        int err = 0;
 
-       if (ve->is_pseudosuper)
+       if (ve_current_is_pseudosuper(ve))
                return 0;
 
        mutex_lock(&ve->devmnt_mutex);
@@ -3367,8 +3367,16 @@ int ve_devmnt_verify(struct ve_struct *ve, dev_t dev, 
char *opts, bool new_mount
 
 static inline int ve_try_reserve_mount(struct ve_struct *ve)
 {
-       int ret = ve_is_super(ve) || ve->is_pseudosuper ||
-                 ve_is_super(get_exec_env());
+       struct mm_struct *mm = current->mm;
+       /*
+        * A host task that joined @ve after it started, such as the CRIU
+        * helper that mounts proc for a nested pid namespace, is not a setup
+        * task but still skips the limit while @ve is pseudosuper.
+        */
+       bool host_entered = ve->is_pseudosuper && task_ve(current) == ve &&
+                           mm && mm->vps_dumpable == VD_VE_ENTER_TASK;
+       int ret = ve_is_super(ve) || ve_current_is_pseudosuper(ve) ||
+                 ve_is_super(get_exec_env()) || host_entered;
        /* Ignore limits in ve0 and pseudosuper cases, but still count. */
        if (ret)
                atomic_dec(&ve->mnt_avail_nr);
-- 
2.43.0

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

Reply via email to