[CRIU] [PATCH 5/8] parasite: restore registers after each parasite command
Andrew Vagin
avagin at parallels.com
Mon Jul 15 15:19:50 EDT 2013
On Mon, Jul 15, 2013 at 09:03:42PM +0400, Pavel Emelyanov wrote:
> On 07/11/2013 01:46 PM, Andrey Vagin wrote:
> > Currenly we can restore blocking signals with help ptrace,
> > so if registers are restored after command, a process state
> > will not be corrupted if criu crashes.
>
> If criu crashes the sigreturn rescue code will restore the regs. No?
Yes, but two commands are required, that a parasite is able to restore
itself via sigreturn:
* allocate parasite_ctl
* parasite_init_daemon()
crtools can crash between these two commands, so we need this and
previos patch. This logic is used for dumping threads too.
>
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> > parasite-syscall.c | 19 +++++++------------
> > 1 file changed, 7 insertions(+), 12 deletions(-)
> >
> > diff --git a/parasite-syscall.c b/parasite-syscall.c
> > index 2b9877c..07b45bc 100644
> > --- a/parasite-syscall.c
> > +++ b/parasite-syscall.c
> > @@ -84,7 +84,7 @@ int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid,
> >
> > if (ptrace(PTRACE_SETREGS, pid, NULL, regs)) {
> > pr_perror("Can't set registers (pid: %d)", pid);
> > - goto err;
> > + goto err_sigmask;
> > }
> >
> > /*
> > @@ -130,7 +130,13 @@ int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid,
> > * parasite code. So we're done.
> > */
> > ret = 0;
> > +
> > err:
> > + if (ptrace(PTRACE_SETREGS, pid, NULL, regs_orig)) {
> > + pr_perror("Can't restore registers (pid: %d)", pid);
> > + ret = -1;
> > + }
> > +err_sigmask:
> > if (ptrace(PTRACE_SETSIGMASK, pid, sizeof(k_rtsigset_t), &sigmask)) {
> > pr_perror("Can't block signals");
> > ret = -1;
> > @@ -164,12 +170,6 @@ static int parasite_execute_trap_by_pid(unsigned int cmd,
> > if (ret)
> > pr_err("Parasite exited with %d\n", ret);
> >
> > - if (ctl->pid.real != pid)
> > - if (ptrace(PTRACE_SETREGS, pid, NULL, regs_orig)) {
> > - pr_perror("Can't restore registers (pid: %d)", pid);
> > - return -1;
> > - }
> > -
> > return ret;
> > }
> >
> > @@ -864,11 +864,6 @@ int parasite_cure_remote(struct parasite_ctl *ctl)
> > ret = -1;
> > }
> >
> > - if (ptrace(PTRACE_SETREGS, ctl->pid.real, NULL, &ctl->regs_orig)) {
> > - pr_err("Can't restore registers (pid: %d)\n", ctl->pid.real);
> > - ret = -1;
> > - }
> > -
> > return ret;
> > }
> >
> >
>
>
More information about the CRIU
mailing list