[CRIU] Re: [PATCH cr] restore: use a currect stack for new processes
Cyrill Gorcunov
gorcunov at openvz.org
Fri Aug 24 15:08:32 EDT 2012
On Fri, Aug 24, 2012 at 10:27:44PM +0400, Andrey Vagin wrote:
>
> - stack = mmap(NULL, STACK_SIZE, PROT_WRITE | PROT_READ,
> - MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS, -1, 0);
> - if (stack == MAP_FAILED) {
> - pr_perror("Failed to map stack for the child");
> - goto err;
> - }
> -
> ca.item = item;
> ca.clone_flags = ns_clone_flags;
>
> @@ -544,7 +537,10 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone
> if (netns_pre_create())
> goto err_unlock;
>
> - ret = clone(restore_task_with_children, stack + STACK_SIZE,
> + asm ("mov %%rsp, %0" : "=r" (stack));
> + stack -= PAGE_SIZE;
> +
> + ret = clone(restore_task_with_children, stack,
> ca.clone_flags | SIGCHLD, &ca);
>
This looks a bit hackish for me but I can live with that ;)
I wonder what would happen if curren sp somewhere near stack bottom
and your "- page_size" move sp to some different VMA which doesn't
even belong to original stack VMA?
Cyrill
More information about the CRIU
mailing list