Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759595AbcJZBex (ORCPT ); Tue, 25 Oct 2016 21:34:53 -0400 Received: from ozlabs.org ([103.22.144.67]:59439 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754631AbcJZBev (ORCPT ); Tue, 25 Oct 2016 21:34:51 -0400 From: Rusty Russell To: Aaron Tomlin , linux-kernel@vger.kernel.org Cc: rostedt@goodmis.org, "Jessica Yu" Subject: Re: [RFC PATCH 1/2] module: Ensure a module's state is set accordingly during module coming cleanup code In-Reply-To: <1476980293-19062-2-git-send-email-atomlin@redhat.com> References: <1476980293-19062-1-git-send-email-atomlin@redhat.com> <1476980293-19062-2-git-send-email-atomlin@redhat.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Wed, 26 Oct 2016 11:24:32 +1030 Message-ID: <87funk3p6f.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: 1301 Lines: 41 Aaron Tomlin writes: > In load_module() in the event of an error, for e.g. unknown module > parameter(s) specified we go to perform some module coming clean up > operations. At this point the module is still in a "formed" state > when it is actually going away. > > This patch updates the module's state accordingly to ensure anyone on the > module_notify_list waiting for a module going away notification will be > notified accordingly. I recall a similar proposal before. I've audited all the subscribers to check they didn't look at mod->state; they seem OK. We actually do this in the init-failed path, so this should be OK. Acked-by: Rusty Russell Thanks, Rusty. > Signed-off-by: Aaron Tomlin > --- > kernel/module.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/module.c b/kernel/module.c > index f57dd63..ff93ab8 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3708,6 +3708,7 @@ static int load_module(struct load_info *info, const char __user *uargs, > sysfs_cleanup: > mod_sysfs_teardown(mod); > coming_cleanup: > + mod->state = MODULE_STATE_GOING; > blocking_notifier_call_chain(&module_notify_list, > MODULE_STATE_GOING, mod); > klp_module_going(mod); > -- > 2.5.5