[CRIU] [PATCH cr] parasite: fix size of cmd

Andrey Vagin avagin at openvz.org
Tue Oct 2 15:32:09 EDT 2012


cmd is declarated in parasite-head-x86-64.S
__export_parasite_cmd:
        .long 0

Its size is 8 bytes, so it should be int instead of long.

This patch fixes a bug in parasite execute,
where a part of args are overwritten by cmd.

memcpy(ctl->addr_cmd, &cmd, sizeof(cmd));

Reported-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 parasite-syscall.c |    4 ++--
 parasite.c         |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/parasite-syscall.c b/parasite-syscall.c
index a912d30..788d238 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -221,7 +221,7 @@ err:
 	return ret;
 }
 
-static int parasite_execute_by_pid(unsigned long cmd, struct parasite_ctl *ctl,
+static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl,
 			    pid_t pid,
 			    void *args, int args_size)
 {
@@ -265,7 +265,7 @@ static int parasite_execute_by_pid(unsigned long cmd, struct parasite_ctl *ctl,
 	return ret;
 }
 
-static int parasite_execute(unsigned long cmd, struct parasite_ctl *ctl,
+static int parasite_execute(unsigned int cmd, struct parasite_ctl *ctl,
 			    void *args, int args_size)
 {
 	return parasite_execute_by_pid(cmd, ctl, ctl->pid, args, args_size);
diff --git a/parasite.c b/parasite.c
index 8c5a4d5..b9ae330 100644
--- a/parasite.c
+++ b/parasite.c
@@ -453,7 +453,7 @@ static int fini(void)
 	return 0;
 }
 
-int __used parasite_service(unsigned long cmd, void *args)
+int __used parasite_service(unsigned int cmd, void *args)
 {
 	BUILD_BUG_ON(sizeof(struct parasite_dump_pages_args) > PARASITE_ARG_SIZE);
 	BUILD_BUG_ON(sizeof(struct parasite_init_args) > PARASITE_ARG_SIZE);
-- 
1.7.1



More information about the CRIU mailing list