From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932349AbbCCTgP (ORCPT ); Tue, 3 Mar 2015 14:36:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45814 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932261AbbCCTgN (ORCPT ); Tue, 3 Mar 2015 14:36:13 -0500 Date: Tue, 3 Mar 2015 13:35:39 -0600 From: Josh Poimboeuf To: Petr Mladek Cc: Seth Jennings , Jiri Kosina , Rusty Russell , Miroslav Benes , Masami Hiramatsu , mingo@kernel.org, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de Subject: Re: [RFC PATCH] livepatch/module: Do not patch modules that are not ready Message-ID: <20150303193539.GB31987@treble.redhat.com> References: <1425382709-9934-1-git-send-email-pmladek@suse.cz> <20150303145517.GA16889@treble.redhat.com> <20150303173456.GH3703@dhcp128.suse.cz> <20150303193128.GA31987@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150303193128.GA31987@treble.redhat.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 03, 2015 at 01:31:28PM -0600, Josh Poimboeuf wrote: > @@ -89,16 +89,29 @@ static bool klp_is_object_loaded(struct klp_object *obj) > /* sets obj->mod if object is not vmlinux and module is found */ > static void klp_find_object_module(struct klp_object *obj) > { > - if (!klp_is_module(obj)) > + struct module *mod; > + > + if (!klp_is_module(obj) || obj->mod) > return; > > mutex_lock(&module_mutex); > + > /* > * We don't need to take a reference on the module here because we have > * the klp_mutex, which is also taken by the module notifier. This > * prevents any module from unloading until we release the klp_mutex. > */ > - obj->mod = find_module(obj->name); > + mod = find_module(obj->name); > + > + /* > + * MODULE_STATE_COMING means we got to the module first before the > + * notifier did. ftrace is already initialized, so it's fine to go > + * ahead and start using it. > + */ This comment should probably be improved to say: "MODULE_STATE_COMING and !obj->mod means..." -- Josh