Commit 86a07778 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

parasite: restore registers after each parasite command

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.

Same as with previous patch -- at the end there will be only
two trap commands, so this is OK.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2db92dee
...@@ -84,7 +84,7 @@ int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid, ...@@ -84,7 +84,7 @@ int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid,
if (ptrace(PTRACE_SETREGS, pid, NULL, regs)) { if (ptrace(PTRACE_SETREGS, pid, NULL, regs)) {
pr_perror("Can't set registers (pid: %d)", pid); 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, ...@@ -130,7 +130,13 @@ int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid,
* parasite code. So we're done. * parasite code. So we're done.
*/ */
ret = 0; ret = 0;
err: 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)) { if (ptrace(PTRACE_SETSIGMASK, pid, sizeof(k_rtsigset_t), &sigmask)) {
pr_perror("Can't block signals"); pr_perror("Can't block signals");
ret = -1; ret = -1;
...@@ -164,12 +170,6 @@ static int parasite_execute_trap_by_pid(unsigned int cmd, ...@@ -164,12 +170,6 @@ static int parasite_execute_trap_by_pid(unsigned int cmd,
if (ret) if (ret)
pr_err("Parasite exited with %d\n", 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; return ret;
} }
...@@ -864,11 +864,6 @@ int parasite_cure_remote(struct parasite_ctl *ctl) ...@@ -864,11 +864,6 @@ int parasite_cure_remote(struct parasite_ctl *ctl)
ret = -1; 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; return ret;
} }
......
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