Commit 833b1f95 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

parasite: stop task on exit from a specified syscall

This patch adds nothing new, just splits the existant function.

Currently a parasite stopped on sigreturn for unmaping a parasite blob.
The same scheme will be used for restorer blob and this function will be
used to stop on exit from the munmap syscall.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5a374819
...@@ -114,4 +114,5 @@ extern bool arch_can_dump_task(pid_t pid); ...@@ -114,4 +114,5 @@ extern bool arch_can_dump_task(pid_t pid);
extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid, extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
struct vm_area_list *vma_area_list); struct vm_area_list *vma_area_list);
extern int parasite_stop_on_syscall(pid_t pid, int sys_nr);
#endif /* __CR_PARASITE_SYSCALL_H__ */ #endif /* __CR_PARASITE_SYSCALL_H__ */
...@@ -759,6 +759,17 @@ static int parasite_fini_seized(struct parasite_ctl *ctl) ...@@ -759,6 +759,17 @@ static int parasite_fini_seized(struct parasite_ctl *ctl)
if (ret) if (ret)
return -1; return -1;
if (parasite_stop_on_syscall(pid, __NR_rt_sigreturn))
return -1;
return 0;
}
int parasite_stop_on_syscall(pid_t pid, const int sys_nr)
{
user_regs_struct_t regs;
int status, ret;
/* Stop all threads on the enter point in sys_rt_sigreturn */ /* Stop all threads on the enter point in sys_rt_sigreturn */
while (1) { while (1) {
if (wait4(pid, &status, __WALL, NULL) < 0) { if (wait4(pid, &status, __WALL, NULL) < 0) {
...@@ -783,7 +794,7 @@ static int parasite_fini_seized(struct parasite_ctl *ctl) ...@@ -783,7 +794,7 @@ static int parasite_fini_seized(struct parasite_ctl *ctl)
} }
pr_debug("%d is going to execute the syscall %lx\n", pid, REG_SYSCALL_NR(regs)); pr_debug("%d is going to execute the syscall %lx\n", pid, REG_SYSCALL_NR(regs));
if (REG_SYSCALL_NR(regs) == __NR_rt_sigreturn) { if (REG_SYSCALL_NR(regs) == sys_nr) {
pr_debug("%d was stopped\n", pid); pr_debug("%d was stopped\n", pid);
break; break;
} }
...@@ -812,7 +823,7 @@ static int parasite_fini_seized(struct parasite_ctl *ctl) ...@@ -812,7 +823,7 @@ static int parasite_fini_seized(struct parasite_ctl *ctl)
return -1; return -1;
} }
return ret; return 0;
} }
int parasite_cure_remote(struct parasite_ctl *ctl) int parasite_cure_remote(struct parasite_ctl *ctl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment