Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754157AbbENBbK (ORCPT ); Wed, 13 May 2015 21:31:10 -0400 Received: from mail-wi0-f195.google.com ([209.85.212.195]:34939 "EHLO mail-wi0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753402AbbENBbI (ORCPT ); Wed, 13 May 2015 21:31:08 -0400 Date: Thu, 14 May 2015 09:31:01 +0800 From: Minfei Huang To: Josh Poimboeuf Cc: mbenes@suse.cz, sjenning@redhat.com, jkosina@suse.cz, vojtech@suse.cz, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, mhuang@redhat.com Subject: Re: [PATCH v3] livepatch: Prevent to apply the patch once coming module notifier fails Message-ID: <20150514013101.GA22152@dhcp-129-218.nay.redhat.com> References: <1431439484-44530-1-git-send-email-mnfhuang@gmail.com> <20150513141415.GB28284@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150513141415.GB28284@treble.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3115 Lines: 100 On 05/13/15 at 09:14P, Josh Poimboeuf wrote: > On Tue, May 12, 2015 at 10:04:44PM +0800, Minfei Huang wrote: > > @@ -883,7 +883,7 @@ int klp_register_patch(struct klp_patch *patch) > > } > > EXPORT_SYMBOL_GPL(klp_register_patch); > > > > -static void klp_module_notify_coming(struct klp_patch *patch, > > +static int klp_module_notify_coming(struct klp_patch *patch, > > struct klp_object *obj) > > { > > struct module *pmod = patch->mod; > > @@ -891,22 +891,24 @@ static void klp_module_notify_coming(struct klp_patch *patch, > > int ret; > > > > ret = klp_init_object_loaded(patch, obj); > > - if (ret) > > - goto err; > > + if (ret) { > > + pr_warn("failed to initialize the patch '%s' (%d)\n", > > + pmod->name, ret); > > + goto out; > > + } > > Can you change it to: > > "failed to initialize the patch '%s' for module '%s' (%d)\n" ? > > That would make it more consistent with the other error message and > identify the failing module. > > Also, the indentation should be fixed on the second pr_warn() line. > Will modify. > > > > if (patch->state == KLP_DISABLED) > > - return; > > + goto out; > > > > pr_notice("applying patch '%s' to loading module '%s'\n", > > pmod->name, mod->name); > > > > ret = klp_enable_object(obj); > > - if (!ret) > > - return; > > - > > -err: > > - pr_warn("failed to apply patch '%s' to module '%s' (%d)\n", > > - pmod->name, mod->name, ret); > > + if (ret) > > + pr_warn("failed to apply patch '%s' to module '%s' (%d)\n", > > + pmod->name, mod->name, ret); > > Bad indentation here too. > > > @@ -930,6 +932,7 @@ disabled: > > static int klp_module_notify(struct notifier_block *nb, unsigned long action, > > void *data) > > { > > + int ret; > > struct module *mod = data; > > struct klp_patch *patch; > > struct klp_object *obj; > > @@ -955,7 +958,13 @@ static int klp_module_notify(struct notifier_block *nb, unsigned long action, > > > > if (action == MODULE_STATE_COMING) { > > obj->mod = mod; > > - klp_module_notify_coming(patch, obj); > > + ret = klp_module_notify_coming(patch, obj); > > + if (ret) { > > + obj->mod = NULL; > > + pr_warn("patch '%s' is dead, remove it " > > + "or re-install the module '%s'\n", > > + patch->mod->name, obj->name); > > + } > > The patch isn't necessarily dead, since it might also include previously > enabled changes for vmlinux or other modules. It can actually be a > dangerous condition if there's a mismatch between old code in the module > and new code elsewhere. How about something like: > > "patch '%s' is in an inconsistent state!\n" > > Also, there's no need to split up the string literal into two lines. > It's ok for a line to have more than 80 columns in that case. > Thanks for your reviewing. Will modify the patch. Thanks Minfei > -- > Josh -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/