Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1640565

Re: [PATCH v2] pid_ns: Fix race between setns'ed fork() and zap_pid_ns_processes()

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] pid_ns: Fix race between setns'ed fork() and zap_pid_ns_processes()
Date 2017-05-12 18:20 +0200
Message-ID <tGlsl-76m-9@gated-at.bofh.it> (permalink)
References <tGlsl-76m-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 05/12, Kirill Tkhai wrote:
>
 --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1845,11 +1845,13 @@ static __latent_entropy struct task_struct *copy_process(
>  	*/
>  	recalc_sigpending();
>  	if (signal_pending(current)) {
> -		spin_unlock(&current->sighand->siglock);
> -		write_unlock_irq(&tasklist_lock);
>  		retval = -ERESTARTNOINTR;
>  		goto bad_fork_cancel_cgroup;
>  	}
> +	if (unlikely(!(ns_of_pid(pid)->nr_hashed & PIDNS_HASH_ADDING))) {
> +		retval = -ENOMEM;
> +		goto bad_fork_cancel_cgroup;
> +	}
>  
>  	if (likely(p->pid)) {
>  		ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
> @@ -1907,6 +1909,8 @@ static __latent_entropy struct task_struct *copy_process(
>  	return p;
>  
>  bad_fork_cancel_cgroup:
> +	spin_unlock(&current->sighand->siglock);
> +	write_unlock_irq(&tasklist_lock);
>  	cgroup_cancel_fork(p);

Looks good to me.

Oleg.

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2] pid_ns: Fix race between setns'ed fork() and         zap_pid_ns_processes() Oleg Nesterov <oleg@redhat.com> - 2017-05-12 18:20 +0200
  Re: [PATCH v2] pid_ns: Fix race between setns'ed fork() and zap_pid_ns_processes() ebiederm@xmission.com (Eric W. Biederman) - 2017-05-12 18:50 +0200
    Re: [PATCH v2] pid_ns: Fix race between setns'ed fork() and  zap_pid_ns_processes() Oleg Nesterov <oleg@redhat.com> - 2017-05-12 19:10 +0200

csiph-web