[CRIU] [PATCH 2/6] parasite: Add a copy of original registers in control block

Cyrill Gorcunov gorcunov at openvz.org
Tue Feb 14 08:41:57 EST 2012


We need to restore unmodified registers in parasite_cure_seized since parasite
itself might leave them in undefined state. In most case it's not that important
since we usually kills task we've dumped.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/parasite-syscall.h |    1 +
 parasite-syscall.c         |    9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 8261ec0..0295d43 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -17,6 +17,7 @@ struct parasite_ctl {
 	void *			remote_map;		/* address inside alien process */
 	void *			local_map;		/* alien remapped in own space */
 	unsigned long		map_length;		/* length of mapped area */
+	user_regs_struct_t	regs_orig;		/* original registers */
 	unsigned long		parasite_ip;		/* service routine start ip */
 	void *			addr_cmd;		/* addr for command */
 	void *			addr_args;		/* address for arguments */
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 14b17c5..08d47d4 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -498,13 +498,13 @@ out:
 
 int parasite_cure_seized(struct parasite_ctl *ctl, struct list_head *vma_area_list)
 {
-	user_regs_struct_t regs, regs_orig;
+	user_regs_struct_t regs;
 	struct vma_area *vma_area;
 	int ret = -1;
 	parasite_status_t args = { };
 
 	ret = parasite_execute(PARASITE_CMD_FINI, ctl,
-			&args, sizeof(args));
+			       &args, sizeof(args));
 	if (ret) {
 		pr_err("Can't finalize parasite (pid: %d) task\n", ctl->pid);
 		goto err;
@@ -512,8 +512,6 @@ int parasite_cure_seized(struct parasite_ctl *ctl, struct list_head *vma_area_li
 
 	jerr(ptrace(PTRACE_GETREGS, ctl->pid, NULL, &regs), err);
 
-	regs_orig = regs;
-
 	vma_area = get_vma_by_ip(vma_area_list, regs.ip);
 	if (!vma_area) {
 		pr_err("No suitable VMA found to run cure (pid: %d)\n", ctl->pid);
@@ -526,7 +524,7 @@ int parasite_cure_seized(struct parasite_ctl *ctl, struct list_head *vma_area_li
 	if (ret)
 		pr_err("munmap_seized failed (pid: %d)\n", ctl->pid);
 
-	if (ptrace(PTRACE_SETREGS, ctl->pid, NULL, &regs_orig)) {
+	if (ptrace(PTRACE_SETREGS, ctl->pid, NULL, &ctl->regs_orig)) {
 		pr_panic("PTRACE_SETREGS failed (pid: %d)\n", ctl->pid);
 		ret = -1;
 	}
@@ -601,6 +599,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, int pid_dir, struct list_
 	ctl->parasite_ip	= PARASITE_HEAD_ADDR((unsigned long)ctl->remote_map);
 	ctl->addr_cmd		= (void *)PARASITE_CMD_ADDR((unsigned long)ctl->local_map);
 	ctl->addr_args		= (void *)PARASITE_ARGS_ADDR((unsigned long)ctl->local_map);
+	ctl->regs_orig		= regs_orig;
 
 	ret = parasite_init(ctl, pid);
 	if (ret) {
-- 
1.7.7.6



More information about the CRIU mailing list