[CRIU] [PATCH 16/16] pie: Use PIE_SIZE helper

Cyrill Gorcunov gorcunov at openvz.org
Thu Jun 4 14:04:17 PDT 2015


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-restore.c       |  6 +-----
 parasite-syscall.c | 10 ++--------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 68bc0b2940fe..4621bec58797 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2358,11 +2358,7 @@ static int prepare_restorer_blob(void)
 	 * in turn will lead to set-exe-file prctl to fail with EBUSY.
 	 */
 
-#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
-	restorer_len = round_up(sizeof(restorer_blob) + nr_gotpcrel * sizeof(long), PAGE_SIZE);
-#else
-	restorer_len = round_up(sizeof(restorer_blob), PAGE_SIZE);
-#endif
+	restorer_len = PIE_SIZE(restorer_blob);
 	restorer = mmap(NULL, restorer_len,
 			PROT_READ | PROT_WRITE | PROT_EXEC,
 			MAP_PRIVATE | MAP_ANON, 0, 0);
diff --git a/parasite-syscall.c b/parasite-syscall.c
index b5776090076a..d6e9ce069c92 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -39,12 +39,6 @@
 #include "asm/restorer.h"
 #include "pie/pie-relocs.h"
 
-#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
-# define parasite_size		(round_up(sizeof(parasite_blob) + nr_gotpcrel * sizeof(long), PAGE_SIZE))
-#else
-# define parasite_size		(round_up(sizeof(parasite_blob), PAGE_SIZE))
-#endif
-
 static int can_run_syscall(unsigned long ip, unsigned long start, unsigned long end)
 {
 	return ip >= start && ip < (end - code_syscall_size);
@@ -1210,7 +1204,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 
 	ctl->args_size = round_up(parasite_args_size, PAGE_SIZE);
 	parasite_args_size = PARASITE_ARG_SIZE_MIN; /* reset for next task */
-	map_exchange_size = parasite_size + ctl->args_size;
+	map_exchange_size = PIE_SIZE(parasite_blob) + ctl->args_size;
 	map_exchange_size += RESTORE_STACK_SIGFRAME + PARASITE_STACK_SIZE;
 	if (item->nr_threads > 1)
 		map_exchange_size += PARASITE_STACK_SIZE;
@@ -1232,7 +1226,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	ctl->addr_cmd		= parasite_sym(ctl->local_map, __export_parasite_cmd);
 	ctl->addr_args		= parasite_sym(ctl->local_map, __export_parasite_args);
 
-	p = parasite_size + ctl->args_size;
+	p = PIE_SIZE(parasite_blob) + ctl->args_size;
 
 	ctl->rsigframe	= ctl->remote_map + p;
 	ctl->sigframe	= ctl->local_map  + p;
-- 
2.4.2



More information about the CRIU mailing list