[CRIU] Re: [PATCH] dump: Fix test for syscall return

Cyrill Gorcunov gorcunov at openvz.org
Fri Feb 10 09:52:35 EST 2012


On Fri, Feb 10, 2012 at 06:44:54PM +0400, Pavel Emelyanov wrote:
> Comment sucks.
> 

Would such one be better?

	Cyrill
---
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Fri, 10 Feb 2012 18:34:09 +0400
Subject: [PATCH] dump: Fix test for syscall return

Only the low 32 bits of orig_ax are meaningful
for obtaining syscall number so we need to test
if sign extended bits are greater than 0.

Reported-by: Kir Kolyshkin <kir at openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-dump.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 97c0ca6..2251d96 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -582,21 +582,21 @@ static int get_task_regs(pid_t pid, struct core_entry *core)
 	jerr(ptrace(PTRACE_GETFPREGS,	pid, NULL, &fpregs), err);
 
 	/* Did we come from a system call? */
-	if (regs.orig_ax >= 0)
+	if ((int)regs.orig_ax >= 0) {
 		/* Restart the system call */
-		switch (regs.ax) {
+		switch ((long)(int)regs.ax) {
 		case -ERESTARTNOHAND:
 		case -ERESTARTSYS:
 		case -ERESTARTNOINTR:
 			regs.ax = regs.orig_ax;
 			regs.ip -= 2;
 			break;
-
 		case -ERESTART_RESTARTBLOCK:
 			regs.ax = __NR_restart_syscall;
 			regs.ip -= 2;
 			break;
 		}
+	}
 
 	assign_reg(core->arch.gpregs, regs,		r15);
 	assign_reg(core->arch.gpregs, regs,		r14);
-- 
1.7.7.6



More information about the CRIU mailing list