lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20090910093623.4d655410.kamezawa.hiroyu@jp.fujitsu.com>
Date:	Thu, 10 Sep 2009 09:36:23 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Roland McGrath <roland@...hat.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH -mm 1/2] do_wait-wakeup-optimization: fix
 child_wait_callback()->eligible_child() usage

On Tue, 1 Sep 2009 14:23:25 +0200
Oleg Nesterov <oleg@...hat.com> wrote:

> (on top of do_wait-wakeup-optimization-child_wait_callback-check-__wnothread-case.patch,
>  fixes do_wait-wakeup-optimization-change-__wake_up_parent-to-use-filtered-wakeup.patch)
> 
> child_wait_callback()->eligible_child() is not right, we can miss the
> wakeup if the task was detached before __wake_up_parent() and the caller
> of do_wait() didn't use __WALL.
> 
> Move ->wo_pid checks from eligible_child() to the new helper, eligible_pid(),
> and change child_wait_callback() to use it instead of eligible_child().
> 
> Note: actually I think it would be better to fix the __WCLONE check in
> eligible_child(), it doesn't look exactly right. But it is not clear what
> is the supposed behaviour, and any change is user-visible.
> 
> Reported-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Confirmed this version works well with my troublesome scripts.

Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>



> ---
> 
>  kernel/exit.c |   15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> --- WAIT/kernel/exit.c~2_WAKE_PARENT_ELIGIBLE_FIX	2009-09-01 12:49:27.000000000 +0200
> +++ WAIT/kernel/exit.c	2009-09-01 12:59:23.000000000 +0200
> @@ -1106,13 +1106,16 @@ static struct pid *task_pid_type(struct 
>  	return pid;
>  }
>  
> -static int eligible_child(struct wait_opts *wo, struct task_struct *p)
> +static inline int eligible_pid(struct wait_opts *wo, struct task_struct *p)
>  {
> -	if (wo->wo_type < PIDTYPE_MAX) {
> -		if (task_pid_type(p, wo->wo_type) != wo->wo_pid)
> -			return 0;
> -	}
> +	return	wo->wo_type == PIDTYPE_MAX ||
> +		task_pid_type(p, wo->wo_type) == wo->wo_pid;
> +}
>  
> +static int eligible_child(struct wait_opts *wo, struct task_struct *p)
> +{
> +	if (!eligible_pid(wo, p))
> +		return 0;
>  	/* Wait for all children (clone and not) if __WALL is set;
>  	 * otherwise, wait for clone children *only* if __WCLONE is
>  	 * set; otherwise, wait for non-clone children *only*.  (Note:
> @@ -1564,7 +1567,7 @@ static int child_wait_callback(wait_queu
>  						child_wait);
>  	struct task_struct *p = key;
>  
> -	if (!eligible_child(wo, p))
> +	if (!eligible_pid(wo, p))
>  		return 0;
>  
>  	if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ