[CRIU] [PATCH v2] user_ns: Block SIGCHLD during namespaces generation

Andrei Vagin avagin at virtuozzo.com
Mon Apr 3 16:57:20 PDT 2017


On Sat, Apr 01, 2017 at 04:05:40PM +0300, Kirill Tkhai wrote:
> We don't want asynchronous signal handler does wait()
> as we do that synchronous. So block the signal.
> 
> v2: Set initial ret = 0
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  criu/namespaces.c |   21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/namespaces.c b/criu/namespaces.c
> index 6637abcb..5e71a3a9 100644
> --- a/criu/namespaces.c
> +++ b/criu/namespaces.c
> @@ -2257,7 +2257,26 @@ static int create_user_ns_hierarhy_fn(void *in_arg)
>  static int create_user_ns_hierarhy(void)
>  {
>  	struct ns_arg arg = { .me = root_user_ns };
> -	return create_user_ns_hierarhy_fn(&arg);
> +	sigset_t blockmask, oldmask;
> +	int ret = 0;
> +
> +	sigemptyset(&blockmask);
> +	sigaddset(&blockmask, SIGCHLD);
> +
> +	if (sigprocmask(SIG_BLOCK, &blockmask, &oldmask) == -1) {
> +		pr_perror("Can not set mask of blocked signals");
> +		return -1;
> +	}

Looks like we have to block sigchld in restore_task_with_children() to
cover all other cases. What do you think about this?

> +
> +	if (create_user_ns_hierarhy_fn(&arg))
> +		ret = -1;
> +
> +	if (sigprocmask(SIG_SETMASK, &oldmask, NULL) == -1) {
> +		pr_perror("Can not unset mask of blocked signals");
> +		ret = -1;
> +	}
> +
> +	return ret;
>  }
>  
>  int prepare_namespace(struct pstree_item *item, unsigned long clone_flags)
> 


More information about the CRIU mailing list