[09/14] pid_ns: Move parent pid_ns's helper check to create_pid_ns_helper()

Submitted by Kirill Tkhai on May 15, 2017, 1:05 p.m.

Details

Message ID 149485354531.681.11030717540445342102.stgit@localhost.localdomain
State New
Series "Refactor pid_ns helpers creation"
Headers show

Commit Message

Kirill Tkhai May 15, 2017, 1:05 p.m.
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@virtuozzo.com>
---
 criu/namespaces.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Patch hide | download patch | download mbox

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");