[CRIU] [PATCH 5/8] dump: Add dumping of alternative signal stack

Andrew Vagin avagin at parallels.com
Tue Jun 18 06:04:52 EDT 2013


On Tue, Jun 18, 2013 at 10:06:55AM +0400, Cyrill Gorcunov wrote:
> 
> [alekskartashov@: use encode_pointer]
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  include/parasite.h |  3 +++
>  parasite-syscall.c | 15 +++++++++++++--
>  pie/parasite.c     |  7 +++++++
>  3 files changed, 23 insertions(+), 2 deletions(-)
> 

> diff --git a/include/parasite.h b/include/parasite.h
> index 25bb7b9..8bfe65c 100644
> --- a/include/parasite.h
> +++ b/include/parasite.h
> @@ -9,6 +9,7 @@
>  #ifndef __ASSEMBLY__
>  
>  #include <sys/un.h>
> +#include <signal.h>
>  
>  #include "image.h"
>  #include "util-net.h"
> @@ -69,6 +70,7 @@ struct parasite_init_args {
>  	k_rtsigset_t		sig_blocked;
>  
>  	struct rt_sigframe	*sigframe;
> +	stack_t			sas;
>  };
>  
>  struct parasite_log_args {
> @@ -145,6 +147,7 @@ struct parasite_dump_thread {
>  	pid_t			tid;
>  	k_rtsigset_t		blocked;
>  	u32			tls;
> +	stack_t			sas;
>  };
>  
>  #define PARASITE_MAX_FDS	(PAGE_SIZE / sizeof(int))
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index 609e3cb..5edc19a 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -369,7 +369,14 @@ static int parasite_set_logfd(struct parasite_ctl *ctl, pid_t pid)
>  	return 0;
>  }
>  
> -static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
> +static void copy_sas(ThreadSasEntry *dst, stack_t *src)
> +{
> +	dst->ss_sp = encode_pointer(src->ss_sp);
> +	dst->ss_size = (u64)src->ss_size;
> +	dst->ss_flags = src->ss_flags;

Do we really need to save flags?

> SS_ONSTACK
>      The process is  currently  executing  on  the  alternate signal
>      stack.   (Note  that  it is not possible to change the alternate
>      signal stack if the process is currently executing on it.)

I don't know why we may want to save this flags.

> SS_DISABLE
>       The alternate signal stack is currently disabled.

for this case we can say core->has_sas = false and don't allocate
ThreadSasEntry

> +}
> +
> +static int parasite_init(struct parasite_ctl *ctl, pid_t pid, struct pstree_item *item)
>  {
>  	static int ssock = -1;
>  
> @@ -420,6 +427,8 @@ static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
>  	ctl->sig_blocked = args->sig_blocked;
>  	ctl->use_sig_blocked = true;
>  
> +	copy_sas(item->core[0]->sas, &args->sas);
> +
>  	sock = accept(ssock, NULL, 0);
>  	if (sock < 0) {
>  		pr_perror("Can't accept connection to the transport socket");
> @@ -515,6 +524,8 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
>  		memcpy(&core->thread_core->blk_sigset,
>  			&args->blocked, sizeof(k_rtsigset_t));
>  		core->thread_core->has_blk_sigset = true;
> +
> +		copy_sas(core->sas, &args->sas);
>  	}
>  
>  	CORE_THREAD_ARCH_INFO(core)->clear_tid_addr = encode_pointer(args->tid_addr);
> @@ -1001,7 +1012,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
>  		p += PARASITE_STACK_SIZE;
>  	}
>  
> -	ret = parasite_init(ctl, pid, item->nr_threads);
> +	ret = parasite_init(ctl, pid, item);
>  	if (ret) {
>  		pr_err("%d: Can't create a transport socket\n", pid);
>  		goto err_restore;
> diff --git a/pie/parasite.c b/pie/parasite.c
> index 6c64166..2503d70 100644
> --- a/pie/parasite.c
> +++ b/pie/parasite.c
> @@ -197,6 +197,9 @@ static int init_thread(struct parasite_dump_thread *args)
>  	args->tid = tid;
>  	args->tls = arch_get_tls();
>  
> +	ret = sys_sigaltstack(NULL, &args->sas);
> +	if (ret)
> +		goto err;
>  
>  	return ret;
>  err:
> @@ -225,6 +228,10 @@ static int init(struct parasite_init_args *args)
>  	if (ret)
>  		return -1;
>  
> +	ret = sys_sigaltstack(NULL, &args->sas);
> +	if (ret)
> +		goto err;
> +
>  	tsock = sys_socket(PF_UNIX, SOCK_STREAM, 0);
>  	if (tsock < 0) {
>  		ret = tsock;



More information about the CRIU mailing list