[CRIU] [PATCH 4/8] parasite: add simplified version of parasite_prep_ctl

Andrey Vagin avagin at openvz.org
Fri Sep 13 05:53:41 EDT 2013


The simplified version of parasite_prep_ctl doesn't search a place for
system call code, which is injected for mapping a parasite blob.

It will be used for unmaping a restorer blob and this blob will contain
all required code for unmapping itself.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/parasite-syscall.h |  1 +
 parasite-syscall.c         | 22 ++++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 3515a30..cb07cb0 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -115,4 +115,5 @@ extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
 			       struct vm_area_list *vma_area_list);
 
 extern int parasite_stop_on_syscall(int tasks, int sys_nr);
+extern struct parasite_ctl *__parasite_prep_ctl(pid_t pid);
 #endif /* __CR_PARASITE_SYSCALL_H__ */
diff --git a/parasite-syscall.c b/parasite-syscall.c
index a8ef03d..65b380b 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -881,10 +881,10 @@ int parasite_cure_seized(struct parasite_ctl *ctl)
 	return ret;
 }
 
-struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_list)
+/* __parasite_prep_ctl() doesn't search a place for injecting code */
+struct parasite_ctl *__parasite_prep_ctl(pid_t pid)
 {
 	struct parasite_ctl *ctl = NULL;
-	struct vma_area *vma_area;
 
 	if (!arch_can_dump_task(pid))
 		goto err;
@@ -899,6 +899,7 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
 	}
 
 	ctl->tsock = -1;
+	ctl->pid.real	= pid;
 
 	if (ptrace(PTRACE_GETSIGMASK, pid, sizeof(k_rtsigset_t), &ctl->sig_blocked)) {
 		pr_perror("ptrace doesn't support PTRACE_GETSIGMASK\n");
@@ -910,6 +911,21 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
 		goto err;
 	}
 
+	return ctl;
+err:
+	xfree(ctl);
+	return NULL;
+}
+
+struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_list)
+{
+	struct vma_area *vma_area;
+	struct parasite_ctl *ctl;
+
+	ctl = __parasite_prep_ctl(pid);
+	if (ctl == NULL)
+		return NULL;
+
 	vma_area = get_vma_by_ip(&vma_area_list->h, REG_IP(ctl->regs_orig));
 	if (!vma_area) {
 		pr_err("No suitable VMA found to run parasite "
@@ -917,8 +933,6 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
 		goto err;
 	}
 
-	ctl->pid.real	= pid;
-	ctl->pid.virt	= 0;
 	ctl->syscall_ip	= vma_area->vma.start;
 
 	return ctl;
-- 
1.8.3.1



More information about the CRIU mailing list