[Devel] [PATCH VZ8 v2 14/14] cgroup/ve: do not run release_agent on non-running ve

Valeriy Vdovin valeriy.vdovin at virtuozzo.com
Wed Feb 10 13:03:05 MSK 2021


cgroup1_release_agent is a function that runs within a private ve workqueue.
When executed, it runs an executable in a userspace by a call to 
call_usermodehelper_ve. There is conflict that when ve is getting shutdown and
some of last cgroups get's deleted at the same time, the workqueue might still
be running, but ve_stop_ns has already been called. ve_stop_ns will stop
usermode helper threads, needed for call_usermodehelper_ve. Because of that a
call to call_usermodehelper_ve will never return, causing a hang.  To defeat
that hang VZ7 code of call_usermodehelper_ve included the check that ve is
still running before running the userspace executable.
It also checked for ve->init_task->flags & PF_EXITING condition. But in VZ8 the
whole usermodehelper infrastructure is much more different. Also VZ8 does not
have ve->init_task in it's fields. That is why it seems more relevant right now
to do ve->is_running check before the call to call_usermodehelper_ve.

Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
 kernel/cgroup/cgroup-v1.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index 993ac38b895f..2521d2727b42 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -937,6 +937,13 @@ void cgroup1_release_agent(struct work_struct *work)
 
 		mutex_unlock(&cgroup_mutex);
 
+		down_write(&ve->op_sem);
+		if (!ve->is_running) {
+			up_write(&ve->op_sem);
+			mutex_lock(&cgroup_mutex);
+			goto continue_free;
+		}
+
 		err = call_usermodehelper_ve(ve, argv[0], argv,
 			envp, UMH_WAIT_EXEC);
 
-- 
2.27.0



More information about the Devel mailing list