[CRIU] [PATCH 2/2] restore: block sigchld to remap task_entries
Andrei Vagin
avagin at openvz.org
Fri Sep 16 02:18:39 PDT 2016
From: Andrei Vagin <avagin at virtuozzo.com>
Currently we remap task_entries but it can be used from a sigchld hanler.
We need to block sigchld to remap task_entries and unlock it
when a restorer sigchld handler is set.
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
criu/cr-restore.c | 11 +++++++++++
criu/pie/restorer.c | 4 ++++
2 files changed, 15 insertions(+)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 8da8ab2..a0e16ee 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2868,6 +2868,8 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
unsigned long creds_pos = 0;
unsigned long creds_pos_next;
+ sigset_t blockmask;
+
pr_info("Restore via sigreturn\n");
/* pr_info_vma_list(&self_vma_list); */
@@ -3000,6 +3002,15 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
}
task_args->breakpoint = &rsti(current)->breakpoint;
+
+ sigemptyset(&blockmask);
+ sigaddset(&blockmask, SIGCHLD);
+
+ if (sigprocmask(SIG_BLOCK, &blockmask, NULL) == -1) {
+ pr_perror("Can not set mask of blocked signals");
+ return -1;
+ }
+
task_args->task_entries = rst_mem_remap_ptr(task_entries_pos, RM_SHREMAP);
task_args->premmapped_addr = (unsigned long)rsti(current)->premmapped_addr;
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 4a96c7e..ac0f475 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1132,6 +1132,10 @@ long __export_restore_task(struct task_restore_args *args)
act.rt_sa_restorer = cr_restore_rt;
sys_sigaction(SIGCHLD, &act, NULL, sizeof(k_rtsigset_t));
+ ksigfillset(&to_block);
+ ksigaddset(&to_block, SIGCHLD);
+ ret = sys_sigprocmask(SIG_UNBLOCK, &to_block, NULL, sizeof(k_rtsigset_t));
+
log_set_fd(args->logfd);
log_set_loglevel(args->loglevel);
--
2.7.4
More information about the CRIU
mailing list