[CRIU] [PATCH 9/9] parasite: restore registers after each parasite command

Andrey Vagin avagin at openvz.org
Fri Jun 21 00:01:15 EDT 2013


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.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 parasite-syscall.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/parasite-syscall.c b/parasite-syscall.c
index 1d4d72b..6736d85 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -187,7 +187,12 @@ retry_signal:
 	 * 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;
+	}
 	return ret;
 }
 
@@ -216,12 +221,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;
 }
 
@@ -977,11 +976,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;
 }
 
-- 
1.8.2.1



More information about the CRIU mailing list