From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH 5/6] kmod: Add new call_usermodehelper_timeout() API Date: Tue, 27 Mar 2012 17:43:05 +0200 Message-ID: <20120327154305.GA19314@redhat.com> References: <4F691059.30405@panasas.com> <4F711EA2.4030608@panasas.com> <4F712246.6030201@panasas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Morton , Tetsuo Handa , linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ingo Molnar , Peter Zijlstra , Paul Turner , Thomas Gleixner , linux-fsdevel , linux-kernel , NFS list , Trond Myklebust , "Bhamare, Sachin" , David Howells , Eric Paris , "Srivatsa S. Bhat" , Kay Sievers , James Morris , "Eric W. Biederman" , Greg KH , "Rafael J. Wysocki" , "keyrings-6DNke4IJHB0gsBAKwltoeQ@public.gmane.org" To: Boaz Harrosh Return-path: Content-Disposition: inline In-Reply-To: <4F712246.6030201-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org> Sender: linux-nfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org Hi Boaz, I'll read this series tomorrow, but On 03/26, Boaz Harrosh wrote: > > int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) > { > DECLARE_COMPLETION_ONSTACK(done); > + int wait_state; > int retval = 0; > > helper_lock(); > @@ -540,19 +541,15 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) > if (wait == UMH_NO_WAIT) /* task has freed sub_info */ > goto unlock; > > - if (wait & UMH_KILLABLE) { > - retval = wait_for_completion_killable(&done); > - if (!retval) > - goto wait_done; > - > + wait_state = (wait & UMH_KILLABLE) ? TASK_KILLABLE : 0; > + retval = wait_for_completion_timeout_state(&done, sub_info->timeout, > + wait_state); > + if (unlikely(retval)) { > /* umh_complete() will see NULL and free sub_info */ > if (xchg(&sub_info->complete, NULL)) > goto unlock; > - /* fallthrough, umh_complete() was already called */ > } > > - wait_for_completion(&done); at first glance this looks certainly wrong, or I misread the patch. We can't remove the "fallback to wait_for_completion" logic until you move the completion into subprocess_info (the next patch seems to do this). xchg() can race with umh_complete(). If it returns NULL, umh_complete() was already called and got ->complete != NULL, we must not return until umh_complete() finishes complete(). Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html