[CRIU] [PATCH v2 08/13] pid_ns: Move parent pid_ns's helper check to create_pid_ns_helper()

Kirill Tkhai ktkhai at virtuozzo.com
Tue May 16 09:26:47 PDT 2017


It's impossible to create a task from a pid_ns if its helper
is not created, because we wait in wait_pid_ns_helper_prepared()
for that. So, such situation here is a bug.
Move the wait and convert it to BUG().

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/namespaces.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 329a2aaf8..9665107eb 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2639,12 +2639,6 @@ static int do_create_pid_ns_helper(void *arg, int sk, pid_t unused_pid)
 		goto err;
 	}
 
-	tmp = ns->parent;
-	if (tmp) {
-		futex_t *f = &tmp->pid.helper_created;
-		futex_wait_while_eq(f, 0);
-	}
-
 	if (switch_ns(root_item->pid->real, &mnt_ns_desc, &mnt_ns_fd) < 0) {
 		pr_err("Can't set mnt_ns\n");
 		goto err;
@@ -2724,6 +2718,7 @@ int create_pid_ns_helper(struct ns_id *ns)
 	int sk;
 
 	BUG_ON(getpid() != INIT_PID);
+	BUG_ON(ns->parent && !futex_get(&ns->parent->pid.helper_created));
 
 	if (__set_next_pid(ns->ns_pid) < 0) {
 		pr_err("Can't set next fd\n");



More information about the CRIU mailing list