mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-28 20:42:49 +00:00
infect: Move parasite_unmap() into infect.c
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
6a4279dd9e
commit
34db99e3c8
6 changed files with 33 additions and 31 deletions
|
|
@ -1658,7 +1658,7 @@ static void finalize_restore(void)
|
|||
if (ctl == NULL)
|
||||
continue;
|
||||
|
||||
parasite_unmap(ctl, (unsigned long)rsti(item)->munmap_restorer);
|
||||
compel_unmap(ctl, (unsigned long)rsti(item)->munmap_restorer);
|
||||
|
||||
xfree(ctl);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,4 @@ struct parasite_ctl {
|
|||
int tsock; /* transport socket for transferring fds */
|
||||
};
|
||||
|
||||
int parasite_run(pid_t pid, int cmd, unsigned long ip, void *stack,
|
||||
user_regs_struct_t *regs, struct thread_ctx *octx);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -56,4 +56,6 @@ extern int compel_execute_syscall(struct parasite_ctl *ctl,
|
|||
extern int compel_run_in_thread(pid_t pid, unsigned int cmd,
|
||||
struct parasite_ctl *ctl,
|
||||
struct thread_ctx *octx);
|
||||
|
||||
extern int compel_unmap(struct parasite_ctl *ctl, unsigned long addr);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ enum trace_flags {
|
|||
|
||||
extern int parasite_stop_on_syscall(int tasks, int sys_nr,
|
||||
int sys_nr_compat, enum trace_flags trace);
|
||||
extern int parasite_unmap(struct parasite_ctl *ctl, unsigned long addr);
|
||||
extern int ptrace_stop_pie(pid_t pid, void *addr, enum trace_flags *tf);
|
||||
|
||||
#endif /* __CR_PARASITE_SYSCALL_H__ */
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ static int restore_child_handler()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parasite_run(pid_t pid, int cmd, unsigned long ip, void *stack,
|
||||
static int parasite_run(pid_t pid, int cmd, unsigned long ip, void *stack,
|
||||
user_regs_struct_t *regs, struct thread_ctx *octx)
|
||||
{
|
||||
k_rtsigset_t block;
|
||||
|
|
@ -738,7 +738,7 @@ int compel_cure_remote(struct parasite_ctl *ctl)
|
|||
args = compel_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))
|
||||
if (compel_unmap(ctl, ctl->parasite_ip))
|
||||
return -1;
|
||||
} else {
|
||||
unsigned long ret;
|
||||
|
|
@ -815,3 +815,30 @@ int compel_run_in_thread(pid_t pid, unsigned int cmd,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* XXX will be removed soon */
|
||||
|
||||
extern int restore_thread_ctx(int pid, struct thread_ctx *ctx);
|
||||
/*
|
||||
* compel_unmap() is used for unmapping parasite and restorer blobs.
|
||||
* A blob can contain code for unmapping itself, so the porcess is
|
||||
* trapped on the exit from the munmap syscall.
|
||||
*/
|
||||
int compel_unmap(struct parasite_ctl *ctl, unsigned long addr)
|
||||
{
|
||||
user_regs_struct_t regs = ctl->orig.regs;
|
||||
pid_t pid = ctl->rpid;
|
||||
int ret = -1;
|
||||
|
||||
ret = parasite_run(pid, PTRACE_SYSCALL, addr, ctl->rstack, ®s, &ctl->orig);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = parasite_stop_on_syscall(1, __NR(munmap, 0),
|
||||
__NR(munmap, 1), TRACE_ENTER);
|
||||
|
||||
if (restore_thread_ctx(pid, &ctl->orig))
|
||||
ret = -1;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ static inline int ptrace_set_regs(int pid, user_regs_struct_t *regs)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int restore_thread_ctx(int pid, struct thread_ctx *ctx)
|
||||
int restore_thread_ctx(int pid, struct thread_ctx *ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
|
@ -796,30 +796,6 @@ goon:
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* parasite_unmap() is used for unmapping parasite and restorer blobs.
|
||||
* A blob can contain code for unmapping itself, so the porcess is
|
||||
* trapped on the exit from the munmap syscall.
|
||||
*/
|
||||
int parasite_unmap(struct parasite_ctl *ctl, unsigned long addr)
|
||||
{
|
||||
user_regs_struct_t regs = ctl->orig.regs;
|
||||
pid_t pid = ctl->rpid;
|
||||
int ret = -1;
|
||||
|
||||
ret = parasite_run(pid, PTRACE_SYSCALL, addr, ctl->rstack, ®s, &ctl->orig);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = parasite_stop_on_syscall(1, __NR(munmap, 0),
|
||||
__NR(munmap, 1), TRACE_ENTER);
|
||||
|
||||
if (restore_thread_ctx(pid, &ctl->orig))
|
||||
ret = -1;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int parasite_mmap_exchange(struct parasite_ctl *ctl, unsigned long size)
|
||||
{
|
||||
int fd;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue