Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYounes Manton <ymanton@ca.ibm.com>2022-09-02 17:01:20 +0300
committerAndrei Vagin <avagin@gmail.com>2022-10-02 08:42:48 +0300
commit6e9a908af9b515e85895354c4dac312c8da52184 (patch)
tree028f651d626586c44407f678246409f7115a05eb
parent58257cb35bb4b2e80b90c3672f626257ecdd34c0 (diff)
compel: Add APIs to facilitate testing
Starting the daemon is the first time we run code in the victim using the parasite stack. It's useful for testing to be able to infect the victim without starting the daemon so that we can inspect the victim's state, set up stack guards, and so on before stack-related corruption can happen. Add compel_infect_no_daemon() to infect the victim but not start the daemon and compel_start_daemon() to start the daemon after the victim is infected. Add compel_get_stack() to get the victim's main and thread parasite stacks. Signed-off-by: Younes Manton <ymanton@ca.ibm.com>
-rw-r--r--compel/include/uapi/infect.h5
-rw-r--r--compel/src/lib/infect.c29
2 files changed, 30 insertions, 4 deletions
diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
index 19d4da2b1..3bd36dda1 100644
--- a/compel/include/uapi/infect.h
+++ b/compel/include/uapi/infect.h
@@ -41,9 +41,12 @@ struct parasite_thread_ctl;
extern struct parasite_ctl __must_check *compel_prepare(int pid);
extern struct parasite_ctl __must_check *compel_prepare_noctx(int pid);
extern int __must_check compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned long args_size);
+extern int __must_check compel_infect_no_daemon(struct parasite_ctl *ctl, unsigned long nr_threads,
+ unsigned long args_size);
extern struct parasite_thread_ctl __must_check *compel_prepare_thread(struct parasite_ctl *ctl, int pid);
extern void compel_release_thread(struct parasite_thread_ctl *);
+extern int __must_check compel_start_daemon(struct parasite_ctl *ctl);
extern int __must_check compel_stop_daemon(struct parasite_ctl *ctl);
extern int __must_check compel_cure_remote(struct parasite_ctl *ctl);
extern int __must_check compel_cure_local(struct parasite_ctl *ctl);
@@ -177,4 +180,6 @@ extern uint64_t compel_get_thread_ip(struct parasite_thread_ctl *tctl);
void compel_set_leader_ip(struct parasite_ctl *ctl, uint64_t v);
void compel_set_thread_ip(struct parasite_thread_ctl *tctl, uint64_t v);
+extern void compel_get_stack(struct parasite_ctl *ctl, void **rstack, void **r_thread_stack);
+
#endif
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 6413a1860..5aab7aa3e 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -967,7 +967,7 @@ static int compel_map_exchange(struct parasite_ctl *ctl, unsigned long size)
return ret;
}
-int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned long args_size)
+int compel_infect_no_daemon(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned long args_size)
{
int ret;
unsigned long p, map_exchange_size, parasite_size = 0;
@@ -1079,15 +1079,23 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
goto err;
}
- if (parasite_start_daemon(ctl))
- goto err;
-
return 0;
err:
return -1;
}
+int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned long args_size)
+{
+ if (compel_infect_no_daemon(ctl, nr_threads, args_size))
+ return -1;
+
+ if (parasite_start_daemon(ctl))
+ return -1;
+
+ return 0;
+}
+
struct parasite_thread_ctl *compel_prepare_thread(struct parasite_ctl *ctl, int pid)
{
struct parasite_thread_ctl *tctl;
@@ -1427,6 +1435,11 @@ static int parasite_fini_seized(struct parasite_ctl *ctl)
return 0;
}
+int compel_start_daemon(struct parasite_ctl *ctl)
+{
+ return parasite_start_daemon(ctl);
+}
+
int compel_stop_daemon(struct parasite_ctl *ctl)
{
if (ctl->daemonized) {
@@ -1772,3 +1785,11 @@ void compel_set_thread_ip(struct parasite_thread_ctl *tctl, uint64_t v)
{
SET_REG_IP(tctl->th.regs, v);
}
+
+void compel_get_stack(struct parasite_ctl *ctl, void **rstack, void **r_thread_stack)
+{
+ if (rstack)
+ *rstack = ctl->rstack;
+ if (r_thread_stack)
+ *r_thread_stack = ctl->r_thread_stack;
+}