[CRIU] [PATCH 8/8] parasite: unmap itself
Andrey Vagin
avagin at openvz.org
Fri Sep 13 05:53:45 EDT 2013
This patch adds a new parasite command, which unmaps the parasite blob.
This command never returns and the criu process traps the target process
on the exit from the munmap syscall.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
include/parasite.h | 6 ++++++
parasite-syscall.c | 19 ++++++++-----------
pie/parasite.c | 12 ++++++++++++
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/include/parasite.h b/include/parasite.h
index e9672ac..4e26967 100644
--- a/include/parasite.h
+++ b/include/parasite.h
@@ -25,6 +25,7 @@ enum {
PARASITE_CMD_INIT_DAEMON,
PARASITE_CMD_DUMP_THREAD,
+ PARASITE_CMD_UNMAP,
/*
* These two must be greater than INITs.
@@ -70,6 +71,11 @@ struct parasite_init_args {
struct rt_sigframe *sigframe;
};
+struct parasite_unmap_args {
+ void *parasite_start;
+ unsigned long parasite_len;
+};
+
struct parasite_vma_entry
{
unsigned long start;
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 9fa7276..c94b1c6 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -307,14 +307,6 @@ int parasite_execute_daemon(unsigned int cmd, struct parasite_ctl *ctl)
return ret;
}
-static int munmap_seized(struct parasite_ctl *ctl, void *addr, size_t length)
-{
- unsigned long x;
-
- return syscall_seized(ctl, __NR_munmap, &x,
- (unsigned long)addr, length, 0, 0, 0, 0);
-}
-
static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)
{
int sun_len;
@@ -846,10 +838,15 @@ int parasite_cure_remote(struct parasite_ctl *ctl)
close_safe(&ctl->tsock);
if (ctl->remote_map) {
- if (munmap_seized(ctl, (void *)ctl->remote_map, ctl->map_length)) {
- pr_err("munmap_seized failed (pid: %d)\n", ctl->pid.real);
+ struct parasite_unmap_args *args;
+
+ *ctl->addr_cmd = PARASITE_CMD_UNMAP;
+
+ args = parasite_args(ctl, struct parasite_unmap_args);
+ args->parasite_start = ctl->remote_map;
+ args->parasite_len = ctl->map_length;
+ if (parasite_unmap(ctl, ctl->parasite_ip))
ret = -1;
- }
}
return ret;
diff --git a/pie/parasite.c b/pie/parasite.c
index 50435d0..ce6376e 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -478,6 +478,16 @@ out:
return 0;
}
+static noinline int parasite_unmap(void *data)
+{
+ struct parasite_unmap_args *args = data;
+
+ sys_munmap(args->parasite_start, args->parasite_len);
+
+ BUG();
+ return -1;
+}
+
static noinline __used int parasite_init_daemon(void *data)
{
struct parasite_init_args *args = data;
@@ -523,6 +533,8 @@ int __used parasite_service(unsigned int cmd, void *args)
return dump_thread(args);
case PARASITE_CMD_INIT_DAEMON:
return parasite_init_daemon(args);
+ case PARASITE_CMD_UNMAP:
+ return parasite_unmap(args);
}
pr_err("Unknown command to parasite: %d\n", cmd);
--
1.8.3.1
More information about the CRIU
mailing list