criu/clone: stack size is too small for Android

Submitted by Zhang, Ning A on April 18, 2019, 2:13 a.m.

Details

Message ID 20190418021358.9281-1-ning.a.zhang@intel.com
State Accepted
Series "criu/clone: stack size is too small for Android"
Commit bcdd276003064c28620cbf221c6cb21e16d2fc86
Headers show

Commit Message

Zhang, Ning A April 18, 2019, 2:13 a.m.
From: Zhang Ning <ning.a.zhang@intel.com>

stack for clone is too small, child process will get
wild pointer, and segfault.

Error (criu/cr-restore.c:1418): 6082 killed by signal 11: Segmentation fault
Error (criu/cr-restore.c:2303): Restoring FAILED.

enlarge stack size to 1024, then no segfault.

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
---
 criu/clone-noasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/clone-noasan.c b/criu/clone-noasan.c
index c44e7196..5ca280eb 100644
--- a/criu/clone-noasan.c
+++ b/criu/clone-noasan.c
@@ -21,7 +21,7 @@ 
  */
 int clone_noasan(int (*fn)(void *), int flags, void *arg)
 {
-	void *stack_ptr = (void *)round_down((unsigned long)&stack_ptr - 256, 16);
+	void *stack_ptr = (void *)round_down((unsigned long)&stack_ptr - 1024, 16);
 	BUG_ON((flags & CLONE_VM) && !(flags & CLONE_VFORK));
 	/*
 	 * Reserve some bytes for clone() internal needs

Comments

Andrei Vagin April 20, 2019, 4:22 p.m.
Applied, thanks!

On Thu, Apr 18, 2019 at 10:13:58AM +0800, ning.a.zhang@intel.com wrote:
> From: Zhang Ning <ning.a.zhang@intel.com>
> 
> stack for clone is too small, child process will get
> wild pointer, and segfault.
> 
> Error (criu/cr-restore.c:1418): 6082 killed by signal 11: Segmentation fault
> Error (criu/cr-restore.c:2303): Restoring FAILED.
> 
> enlarge stack size to 1024, then no segfault.
> 
> Cc: Chen Hu <hu1.chen@intel.com>
> Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
> ---
>  criu/clone-noasan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/clone-noasan.c b/criu/clone-noasan.c
> index c44e7196..5ca280eb 100644
> --- a/criu/clone-noasan.c
> +++ b/criu/clone-noasan.c
> @@ -21,7 +21,7 @@
>   */
>  int clone_noasan(int (*fn)(void *), int flags, void *arg)
>  {
> -	void *stack_ptr = (void *)round_down((unsigned long)&stack_ptr - 256, 16);
> +	void *stack_ptr = (void *)round_down((unsigned long)&stack_ptr - 1024, 16);
>  	BUG_ON((flags & CLONE_VM) && !(flags & CLONE_VFORK));
>  	/*
>  	 * Reserve some bytes for clone() internal needs
> -- 
> 2.20.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu