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

Andrey Vagin avagin at openvz.org
Thu Jul 11 05:46:52 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 | 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;
 }
 
-- 
1.8.3.1



More information about the CRIU mailing list