Commit b5d2b603 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

pstree: Make restore_finish_stage helper to use holder variable

The @task_entries variable is declared as external in
criu/include/pstree.h and restore_finish_stage refers
to it implicitly. This is a bad habbit because the name
get propagated into pie code where we have a local
static variable, which eventually may shadow the former
copy with gcc 4.9 series as been reported by Nikolay.

Lets make restore_finish_stage helper to take variable
name explicitly.
Reported-by: 's avatarNikolay Borisov <kernel@kyup.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 4fd8f396
...@@ -704,7 +704,7 @@ static int restore_one_zombie(CoreEntry *core) ...@@ -704,7 +704,7 @@ static int restore_one_zombie(CoreEntry *core)
prctl(PR_SET_NAME, (long)(void *)core->tc->comm, 0, 0, 0); prctl(PR_SET_NAME, (long)(void *)core->tc->comm, 0, 0, 0);
if (task_entries != NULL) { if (task_entries != NULL) {
restore_finish_stage(CR_STATE_RESTORE); restore_finish_stage(task_entries, CR_STATE_RESTORE);
zombie_prepare_signals(); zombie_prepare_signals();
} }
...@@ -786,7 +786,7 @@ static int restore_one_task(int pid, CoreEntry *core) ...@@ -786,7 +786,7 @@ static int restore_one_task(int pid, CoreEntry *core)
return -1; return -1;
} }
restore_finish_stage(CR_STATE_RESTORE); restore_finish_stage(task_entries, CR_STATE_RESTORE);
if (wait_on_helpers_zombies()) { if (wait_on_helpers_zombies()) {
pr_err("failed to wait on helpers and zombies\n"); pr_err("failed to wait on helpers and zombies\n");
ret = -1; ret = -1;
...@@ -1278,7 +1278,7 @@ static int restore_task_with_children(void *_arg) ...@@ -1278,7 +1278,7 @@ static int restore_task_with_children(void *_arg)
/* Wait prepare_userns */ /* Wait prepare_userns */
if (current->parent == NULL && if (current->parent == NULL &&
restore_finish_stage(CR_STATE_RESTORE_NS) < 0) restore_finish_stage(task_entries, CR_STATE_RESTORE_NS) < 0)
goto err; goto err;
/* /*
...@@ -1314,7 +1314,7 @@ static int restore_task_with_children(void *_arg) ...@@ -1314,7 +1314,7 @@ static int restore_task_with_children(void *_arg)
if (root_prepare_shared()) if (root_prepare_shared())
goto err; goto err;
if (restore_finish_stage(CR_STATE_RESTORE_SHARED) < 0) if (restore_finish_stage(task_entries, CR_STATE_RESTORE_SHARED) < 0)
goto err; goto err;
} }
...@@ -1351,7 +1351,7 @@ static int restore_task_with_children(void *_arg) ...@@ -1351,7 +1351,7 @@ static int restore_task_with_children(void *_arg)
fini_restore_mntns(); fini_restore_mntns();
} }
if (restore_finish_stage(CR_STATE_FORKING) < 0) if (restore_finish_stage(task_entries, CR_STATE_FORKING) < 0)
goto err; goto err;
if (restore_one_task(current->pid.virt, ca->core)) if (restore_one_task(current->pid.virt, ca->core))
......
...@@ -211,10 +211,10 @@ enum { ...@@ -211,10 +211,10 @@ enum {
CR_STATE_COMPLETE CR_STATE_COMPLETE
}; };
#define restore_finish_stage(__stage) ({ \ #define restore_finish_stage(__v, __stage) ({ \
futex_dec_and_wake(&task_entries->nr_in_progress); \ futex_dec_and_wake(&(__v)->nr_in_progress); \
futex_wait_while(&task_entries->start, __stage); \ futex_wait_while(&(__v)->start, __stage); \
(s32) futex_get(&task_entries->start); \ (s32) futex_get(&(__v)->start); \
}) })
......
...@@ -467,18 +467,18 @@ long __export_restore_thread(struct thread_restore_args *args) ...@@ -467,18 +467,18 @@ long __export_restore_thread(struct thread_restore_args *args)
pr_info("%ld: Restored\n", sys_gettid()); pr_info("%ld: Restored\n", sys_gettid());
restore_finish_stage(CR_STATE_RESTORE); restore_finish_stage(task_entries, CR_STATE_RESTORE);
if (restore_signals(args->siginfo, args->siginfo_n, false)) if (restore_signals(args->siginfo, args->siginfo_n, false))
goto core_restore_end; goto core_restore_end;
restore_finish_stage(CR_STATE_RESTORE_SIGCHLD); restore_finish_stage(task_entries, CR_STATE_RESTORE_SIGCHLD);
restore_pdeath_sig(args); restore_pdeath_sig(args);
if (args->ta->seccomp_mode != SECCOMP_MODE_DISABLED) if (args->ta->seccomp_mode != SECCOMP_MODE_DISABLED)
pr_info("Restoring seccomp mode %d for %ld\n", args->ta->seccomp_mode, sys_getpid()); pr_info("Restoring seccomp mode %d for %ld\n", args->ta->seccomp_mode, sys_getpid());
restore_finish_stage(CR_STATE_RESTORE_CREDS); restore_finish_stage(task_entries, CR_STATE_RESTORE_CREDS);
futex_dec_and_wake(&thread_inprogress); futex_dec_and_wake(&thread_inprogress);
...@@ -1352,7 +1352,7 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -1352,7 +1352,7 @@ long __export_restore_task(struct task_restore_args *args)
pr_info("%ld: Restored\n", sys_getpid()); pr_info("%ld: Restored\n", sys_getpid());
restore_finish_stage(CR_STATE_RESTORE); restore_finish_stage(task_entries, CR_STATE_RESTORE);
if (wait_helpers(args) < 0) if (wait_helpers(args) < 0)
goto core_restore_end; goto core_restore_end;
...@@ -1376,7 +1376,7 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -1376,7 +1376,7 @@ long __export_restore_task(struct task_restore_args *args)
if (ret) if (ret)
goto core_restore_end; goto core_restore_end;
restore_finish_stage(CR_STATE_RESTORE_SIGCHLD); restore_finish_stage(task_entries, CR_STATE_RESTORE_SIGCHLD);
rst_tcp_socks_all(args); rst_tcp_socks_all(args);
...@@ -1398,7 +1398,7 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -1398,7 +1398,7 @@ long __export_restore_task(struct task_restore_args *args)
futex_set_and_wake(&thread_inprogress, args->nr_threads); futex_set_and_wake(&thread_inprogress, args->nr_threads);
restore_finish_stage(CR_STATE_RESTORE_CREDS); restore_finish_stage(task_entries, CR_STATE_RESTORE_CREDS);
if (ret) if (ret)
BUG(); BUG();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment