From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966657AbcBDRab (ORCPT ); Thu, 4 Feb 2016 12:30:31 -0500 Received: from mx2.suse.de ([195.135.220.15]:33575 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966607AbcBDR3u (ORCPT ); Thu, 4 Feb 2016 12:29:50 -0500 Date: Thu, 4 Feb 2016 18:29:46 +0100 (CET) From: Miroslav Benes To: Jessica Yu cc: Josh Poimboeuf , Seth Jennings , Jiri Kosina , Vojtech Pavlik , Rusty Russell , Steven Rostedt , Ingo Molnar , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] livepatch/module: remove livepatch module notifier In-Reply-To: <1454375856-27757-3-git-send-email-jeyu@redhat.com> Message-ID: References: <1454375856-27757-1-git-send-email-jeyu@redhat.com> <1454375856-27757-3-git-send-email-jeyu@redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Feb 2016, Jessica Yu wrote: > +/* Called from the module loader during module coming/going states */ > +extern int klp_module_enable(struct module *mod); > +extern void klp_module_disable(struct module *mod); We do not use 'extern' keyword in header files. It is redundant. Unfortunately, the situation differs among header files and it is hard to be consistent. > + /* > + * Each module has to know that the coming handler has > + * been called. We never know what module will get > + * patched by a new patch. > + */ > + mod->klp_alive = true; This comment should fixed too. Note: we still need klp_alive, because the race is still there even without notifiers. > +void klp_module_disable(struct module *mod) > { > - int ret; > - struct module *mod = data; > struct klp_patch *patch; > struct klp_object *obj; > > - if (action != MODULE_STATE_COMING && action != MODULE_STATE_GOING) > - return 0; > + if (mod->state != MODULE_STATE_GOING) > + return; This is similar to what Petr proposed. We must be in MODULE_STATE_GOING here. We could WARN here and return. > diff --git a/kernel/module.c b/kernel/module.c > index b05d466..71c77ed 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3375,6 +3378,10 @@ static int complete_formation(struct module *mod, struct load_info *info) > mutex_unlock(&module_mutex); > > ftrace_module_enable(mod); > + err = klp_module_enable(mod); > + if (err) > + goto out; > + if (err) return err; module_mutex is already unlocked so no need to jump to out. Apart from these minor things and Petr's remarks it looks ok. Thanks for fixing this. Miroslav