[CRIU] [PATCH 5/8] dump: Add dumping of alternative signal stack

Cyrill Gorcunov gorcunov at openvz.org
Mon Jun 17 12:47:45 EDT 2013


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/parasite.h |  3 +++
 parasite-syscall.c | 15 +++++++++++++--
 pie/parasite.c     |  7 +++++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/include/parasite.h b/include/parasite.h
index 25bb7b9..8bfe65c 100644
--- a/include/parasite.h
+++ b/include/parasite.h
@@ -9,6 +9,7 @@
 #ifndef __ASSEMBLY__
 
 #include <sys/un.h>
+#include <signal.h>
 
 #include "image.h"
 #include "util-net.h"
@@ -69,6 +70,7 @@ struct parasite_init_args {
 	k_rtsigset_t		sig_blocked;
 
 	struct rt_sigframe	*sigframe;
+	stack_t			sas;
 };
 
 struct parasite_log_args {
@@ -145,6 +147,7 @@ struct parasite_dump_thread {
 	pid_t			tid;
 	k_rtsigset_t		blocked;
 	u32			tls;
+	stack_t			sas;
 };
 
 #define PARASITE_MAX_FDS	(PAGE_SIZE / sizeof(int))
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 609e3cb..87b3458 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -369,7 +369,14 @@ static int parasite_set_logfd(struct parasite_ctl *ctl, pid_t pid)
 	return 0;
 }
 
-static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
+static void copy_sas(ThreadSasEntry *dst, stack_t *src)
+{
+	dst->ss_sp = (u64)src->ss_sp;
+	dst->ss_size = (u64)src->ss_size;
+	dst->ss_flags = src->ss_flags;
+}
+
+static int parasite_init(struct parasite_ctl *ctl, pid_t pid, struct pstree_item *item)
 {
 	static int ssock = -1;
 
@@ -420,6 +427,8 @@ static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
 	ctl->sig_blocked = args->sig_blocked;
 	ctl->use_sig_blocked = true;
 
+	copy_sas(item->core[0]->sas, &args->sas);
+
 	sock = accept(ssock, NULL, 0);
 	if (sock < 0) {
 		pr_perror("Can't accept connection to the transport socket");
@@ -515,6 +524,8 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 		memcpy(&core->thread_core->blk_sigset,
 			&args->blocked, sizeof(k_rtsigset_t));
 		core->thread_core->has_blk_sigset = true;
+
+		copy_sas(core->sas, &args->sas);
 	}
 
 	CORE_THREAD_ARCH_INFO(core)->clear_tid_addr = encode_pointer(args->tid_addr);
@@ -1001,7 +1012,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 		p += PARASITE_STACK_SIZE;
 	}
 
-	ret = parasite_init(ctl, pid, item->nr_threads);
+	ret = parasite_init(ctl, pid, item);
 	if (ret) {
 		pr_err("%d: Can't create a transport socket\n", pid);
 		goto err_restore;
diff --git a/pie/parasite.c b/pie/parasite.c
index 6c64166..2503d70 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -197,6 +197,9 @@ static int init_thread(struct parasite_dump_thread *args)
 	args->tid = tid;
 	args->tls = arch_get_tls();
 
+	ret = sys_sigaltstack(NULL, &args->sas);
+	if (ret)
+		goto err;
 
 	return ret;
 err:
@@ -225,6 +228,10 @@ static int init(struct parasite_init_args *args)
 	if (ret)
 		return -1;
 
+	ret = sys_sigaltstack(NULL, &args->sas);
+	if (ret)
+		goto err;
+
 	tsock = sys_socket(PF_UNIX, SOCK_STREAM, 0);
 	if (tsock < 0) {
 		ret = tsock;
-- 
1.8.1.4



More information about the CRIU mailing list