From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756406AbZETPVU (ORCPT ); Wed, 20 May 2009 11:21:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755445AbZETPVK (ORCPT ); Wed, 20 May 2009 11:21:10 -0400 Received: from yw-out-2324.google.com ([74.125.46.28]:17394 "EHLO yw-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755376AbZETPVJ (ORCPT ); Wed, 20 May 2009 11:21:09 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:from:to:subject:in-reply-to:references:user-agent :mime-version:content-type; b=q9/CNHupOP+1GnrQ6y0LtFZCT9hJCMhPrQRmnSRrYhtGOLrPcydRBiLJQNuDZHUv+r jrzeq6XoYgmkG/qenS/2ggtoPDG68iPoFKGtI4qJTAtywZfLAw0bFISF7Q1ymdoI5WpD F4V17tzO7dRiwY0ToO+4Iq51iJ3W+PbKTL+cQ= Date: Wed, 20 May 2009 17:21:06 +0200 Message-ID: <87tz3fssv1.wl%vmayatsk@redhat.com> From: Vitaly Mayatskikh To: Andrew Morton , Oleg Nesterov , Ingo Molnar , Roland McGrath , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] Split wait_noreap_copyout() In-Reply-To: <1242048349-2766-2-git-send-email-v.mayatskih@gmail.com> References: <1242048349-2766-1-git-send-email-v.mayatskih@gmail.com> <1242048349-2766-2-git-send-email-v.mayatskih@gmail.com> User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/22.3 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Mon, 11 May 2009 15:25:50 +0200, Vitaly Mayatskikh wrote: > > Move getrusage() and put_user() code from wait_noreap_copyout() > to copy_wait_opts_to_user(). The same code is spreaded across all > wait_task_*() routines, it's better to reuse one copy. > > Signed-off-by: Vitaly Mayatskikh > --- > kernel/exit.c | 39 +++++++++++++++++++++++---------------- > 1 files changed, 23 insertions(+), 16 deletions(-) > > diff --git a/kernel/exit.c b/kernel/exit.c > index 25782da..9546362 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -1123,27 +1123,34 @@ static int eligible_child(struct wait_opts *wo, struct task_struct *p) > return 1; > } > > -static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p, > - pid_t pid, uid_t uid, int why, int status) > +static int copy_wait_opts_to_user(struct wait_opts *wo, struct task_struct *p, > + pid_t pid, uid_t uid, int why, int status, int signal) > { > - struct siginfo __user *infop; > + struct siginfo __user *infop = wo->wo_info; > int retval = wo->wo_rusage > ? getrusage(p, RUSAGE_BOTH, wo->wo_rusage) : 0; > > + if (!retval && infop) { > + retval = put_user(signal, &infop->si_signo); ... > +static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p, > + pid_t pid, uid_t uid, int why, int status) > +{ > + int retval = copy_wait_opts_to_user(wo, p, pid, uid, why, status, SIGCHLD); > put_task_struct(p); > - infop = wo->wo_info; > - if (!retval) > - retval = put_user(SIGCHLD, &infop->si_signo); ... Oleg has pointed me to broken behaviour here. Previously wait_noreap_copyout was doing unconditional put_user and was returning EFAULT when infop is NULL. Now it uses copy_wait_opts_to_user, which checks infop and return NULL in the same case. This change is visible from userspace in waitid() function. There're 2 opportunities how to deal with new behaviour: 1. Assume wait_task_zombie had a bug previously, and let this patch go. 2. Fix copy_wait_opts_to_user to old behaviour by something like: if (!retval && (infop || WNOWAIT)) { What's your opinion? -- wbr, Vitaly