[01/15] restore: Bootstrap len is always page-size aligned

Submitted by Pavel Emelianov on May 24, 2016, 11:33 a.m.

Details

Message ID 57443C10.40103@virtuozzo.com
State Superseded
Commit 4ce47dd3ac3eb63f071deee918611668e058aeb0
Headers show

Commit Message

Pavel Emelianov May 24, 2016, 11:33 a.m.
The restore_bootstrap_len is restorer, args and rst-mem lenghts.

Restorer is pie_size() from restorer, which is page-size aligned.
Args len is aligned to page-size few lines above.
The remapable rst-mem grows page by page and is aligned too.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/cr-restore.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 8e7f18e..6bc339b 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2693,7 +2693,6 @@  static int sigreturn_restore(pid_t pid, CoreEntry *core)
 
 #ifdef CONFIG_VDSO
 	unsigned long vdso_rt_size = 0;
-	unsigned long vdso_rt_delta = 0;
 #endif
 
 	unsigned long aio_rings;
@@ -2792,19 +2791,15 @@  static int sigreturn_restore(pid_t pid, CoreEntry *core)
 
 	rst_mem_size = rst_mem_lock();
 	restore_bootstrap_len = restorer_len + args_len + rst_mem_size;
+	BUG_ON(restore_bootstrap_len & (PAGE_SIZE - 1));
 
 #ifdef CONFIG_VDSO
 	/*
 	 * Figure out how much memory runtime vdso and vvar will need.
 	 */
 	vdso_rt_size = vdso_vma_size(&vdso_sym_rt);
-	if (vdso_rt_size) {
-		vdso_rt_delta = ALIGN(restore_bootstrap_len, PAGE_SIZE) - restore_bootstrap_len;
-		vdso_rt_size += vdso_rt_delta;
-		if (vvar_vma_size(&vdso_sym_rt))
-			vdso_rt_size += ALIGN(vvar_vma_size(&vdso_sym_rt), PAGE_SIZE);
-	}
-
+	if (vdso_rt_size && vvar_vma_size(&vdso_sym_rt))
+		vdso_rt_size += ALIGN(vvar_vma_size(&vdso_sym_rt), PAGE_SIZE);
 	restore_bootstrap_len += vdso_rt_size;
 #endif
 
@@ -3010,7 +3005,7 @@  static int sigreturn_restore(pid_t pid, CoreEntry *core)
 	 * self-vmas are unmaped.
 	 */
 	mem += rst_mem_size;
-	task_args->vdso_rt_parked_at = (unsigned long)mem + vdso_rt_delta;
+	task_args->vdso_rt_parked_at = (unsigned long)mem;
 	task_args->vdso_sym_rt = vdso_sym_rt;
 	task_args->vdso_rt_size = vdso_rt_size;
 #endif

Comments

Cyrill Gorcunov May 24, 2016, 1:34 p.m.
On Tue, May 24, 2016 at 02:33:36PM +0300, Pavel Emelyanov wrote:
> The restore_bootstrap_len is restorer, args and rst-mem lenghts.
> 
> Restorer is pie_size() from restorer, which is page-size aligned.
> Args len is aligned to page-size few lines above.
> The remapable rst-mem grows page by page and is aligned too.
> 
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>