[CRIU] [PATCH 08/16] pie: x86 -- Adjust size of parasite and restorer code

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


In case of @gotpcrel relocations we need additional
space to carry pointers.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-restore.c       | 4 ++++
 parasite-syscall.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/cr-restore.c b/cr-restore.c
index aa00dc2ebe85..bbbfd454df63 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2356,7 +2356,11 @@ 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 = 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 6f1bb66ed07f..e3cf2f8e4cf6 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -38,7 +38,11 @@
 #include "asm/dump.h"
 #include "asm/restorer.h"
 
-#define parasite_size		(round_up(sizeof(parasite_blob), PAGE_SIZE))
+#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)
 {
-- 
2.4.2



More information about the CRIU mailing list