Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935053AbcCJD2T (ORCPT ); Wed, 9 Mar 2016 22:28:19 -0500 Received: from ozlabs.org ([103.22.144.67]:51499 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934869AbcCJD2G (ORCPT ); Wed, 9 Mar 2016 22:28:06 -0500 From: Rusty Russell To: Jessica Yu , Josh Poimboeuf , Seth Jennings , Jiri Kosina , Vojtech Pavlik , Miroslav Benes , Petr Mladek Cc: Steven Rostedt , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: Re: [PATCH 2/3] modules: set mod->state to GOING before going notifiers are called In-Reply-To: <1457561637-24770-3-git-send-email-jeyu@redhat.com> References: <1457561637-24770-1-git-send-email-jeyu@redhat.com> <1457561637-24770-3-git-send-email-jeyu@redhat.com> User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Thu, 10 Mar 2016 13:57:16 +1030 Message-ID: <87a8m7ko6j.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1535 Lines: 42 Jessica Yu writes: > In load_module(), the going notifiers are called during error handling > when an error occurs after the coming notifiers have already been called. > However, a module's state is still MODULE_STATE_COMING when the going > notifiers are called in the error path. To be consistent, also set > mod->state to MODULE_STATE_GOING before calling the going notifiers. > > Signed-off-by: Jessica Yu > --- > kernel/module.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/module.c b/kernel/module.c > index 1981ae0..9e80576 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3494,6 +3494,9 @@ static int load_module(struct load_info *info, const char __user *uargs, > return do_init_module(mod); > > coming_cleanup: > + mutex_lock(&module_mutex); > + mod->state = MODULE_STATE_GOING; > + mutex_unlock(&module_mutex); > blocking_notifier_call_chain(&module_notify_list, > MODULE_STATE_GOING, mod); Actually, reviewing this patch makes me realize it is wrong. We rely on the state of the module being MODULE_STATE_COMING here: static inline int strong_try_module_get(struct module *mod) { BUG_ON(mod && mod->state == MODULE_STATE_UNFORMED); if (mod && mod->state == MODULE_STATE_COMING) return -EBUSY; We will just have to document that the notifier can be called with a module in MODULE_STATE_COMING if it never succeeded its initialization. Sorry for the previously false lead, Rusty.