[CRIU] [PATCH 4/5] restore: Add restoration of alternative signal stack

Pavel Emelyanov xemul at parallels.com
Wed Jul 10 07:55:26 EDT 2013


On 07/10/2013 03:36 PM, Cyrill Gorcunov wrote:
> 
> To restore SAS we have two ways:
> - call for sigaltstack explicitly in restorer.c right before we call for sigreturn
> - pass stack value to sigreturn call and allow the kernel to restore stack for us
> 
> Since second way is a simplier one -- we stick with it.
> 
> [alekskartashov@: use RT_SIGFRAME_UC]
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> CC: Alexander Kartashov <alekskartashov at parallels.com>
> ---
>  cr-restore.c       |  5 +++++
>  include/restorer.h |  2 ++
>  include/sigframe.h | 18 ++++++++++++++++++
>  pie/restorer.c     |  9 +++++++++
>  sigframe.c         | 12 ++++++++++++
>  5 files changed, 46 insertions(+)
> 


> diff --git a/pie/restorer.c b/pie/restorer.c
> index c4171bd..1407c7c 100644
> --- a/pie/restorer.c
> +++ b/pie/restorer.c
> @@ -773,6 +773,15 @@ long __export_restore_task(struct task_restore_core_args *args)
>  		goto core_restore_end;
>  
>  	/*
> +	 * FIXME
> +	 * Alternative signal stack for the group leader
> +	 * is setting up separately from the threads.
> +	 * This better should be unified one day.
> +	 */

Still don't get it. The construct_sigframe is called for every thread
in a group, including the leader one. Why do we need to call this thing
again for the group leader?

> +	if (args->sas.ss_sp != SAS_INVALID_SP)
> +		setup_sas(rt_sigframe, &args->sas);
> +
> +	/*
>  	 * Threads restoration. This requires some more comments. This
>  	 * restorer routine and thread restorer routine has the following
>  	 * memory map, prepared by a caller code.
> diff --git a/sigframe.c b/sigframe.c
> index 68c9776..053bdf0 100644
> --- a/sigframe.c
> +++ b/sigframe.c
> @@ -31,5 +31,17 @@ int construct_sigframe(struct rt_sigframe *sigframe,
>  	if (restore_gpregs(sigframe, CORE_THREAD_ARCH_INFO(core)->gpregs))
>  		return -1;
>  
> +	/*
> +	 * On restore we have 2 ways for sas
> +	 * - either call for sigaltstack explicitly in restorer.c right before
> +	 *   we call for sigreturn
> +	 *
> +	 * - either pass stack value to sigreturn call and allow the kernel to
> +	 *   restore stack for us
> +	 *
> +	 * Second way looks more clean and simple, and here we go.
> +	 */
> +	setup_sas(sigframe, core->thread_core->sas);
> +
>  	return 0;
>  }


More information about the CRIU mailing list