2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-01 06:45:35 +00:00

restore: always kill tasks in error cases

Reported-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Cc: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrew Vagin
2015-11-18 14:04:26 +03:00
committed by Pavel Emelyanov
parent 2f7407342a
commit 9d59bc14ef

View File

@@ -1813,7 +1813,7 @@ static int restore_root_task(struct pstree_item *init)
ret = fork_with_pid(init); ret = fork_with_pid(init);
if (ret < 0) if (ret < 0)
return -1; goto out;
if (root_as_sibling) { if (root_as_sibling) {
struct sigaction act; struct sigaction act;
@@ -1832,7 +1832,7 @@ static int restore_root_task(struct pstree_item *init)
if (ptrace(PTRACE_SEIZE, init->pid.real, 0, 0)) { if (ptrace(PTRACE_SEIZE, init->pid.real, 0, 0)) {
pr_perror("Can't attach to init"); pr_perror("Can't attach to init");
goto out; goto out_kill;
} }
} }
@@ -1841,33 +1841,33 @@ static int restore_root_task(struct pstree_item *init)
* prepare_userns_creds() must be called after filling mappings. * prepare_userns_creds() must be called after filling mappings.
*/ */
if ((root_ns_mask & CLONE_NEWUSER) && prepare_userns(init)) if ((root_ns_mask & CLONE_NEWUSER) && prepare_userns(init))
goto out; goto out_kill;
pr_info("Wait until namespaces are created\n"); pr_info("Wait until namespaces are created\n");
ret = restore_wait_inprogress_tasks(); ret = restore_wait_inprogress_tasks();
if (ret) if (ret)
goto out; goto out_kill;
if (root_ns_mask & CLONE_NEWNS) { if (root_ns_mask & CLONE_NEWNS) {
mnt_ns_fd = open_proc(init->pid.real, "ns/mnt"); mnt_ns_fd = open_proc(init->pid.real, "ns/mnt");
if (mnt_ns_fd < 0) { if (mnt_ns_fd < 0) {
pr_perror("Can't open init's mntns fd"); pr_perror("Can't open init's mntns fd");
goto out; goto out_kill;
} }
} }
ret = run_scripts(ACT_SETUP_NS); ret = run_scripts(ACT_SETUP_NS);
if (ret) if (ret)
goto out; goto out_kill;
timing_start(TIME_FORK); timing_start(TIME_FORK);
ret = restore_switch_stage(CR_STATE_RESTORE_SHARED); ret = restore_switch_stage(CR_STATE_RESTORE_SHARED);
if (ret < 0) if (ret < 0)
goto out; goto out_kill;
ret = restore_switch_stage(CR_STATE_FORKING); ret = restore_switch_stage(CR_STATE_FORKING);
if (ret < 0) if (ret < 0)
goto out; goto out_kill;
timing_stop(TIME_FORK); timing_stop(TIME_FORK);