Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964928AbbBIRb7 (ORCPT ); Mon, 9 Feb 2015 12:31:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55486 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964878AbbBIRbg (ORCPT ); Mon, 9 Feb 2015 12:31:36 -0500 From: Josh Poimboeuf To: Seth Jennings , Jiri Kosina , Vojtech Pavlik Cc: Masami Hiramatsu , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 8/9] livepatch: allow patch modules to be removed Date: Mon, 9 Feb 2015 11:31:20 -0600 Message-Id: <5a1f98566264a40895704d553e9acf8cfda0659c.1423499826.git.jpoimboe@redhat.com> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2595 Lines: 87 Now that we have a consistency model we can detect when unpatching is complete and the patch module can be safely removed. Signed-off-by: Josh Poimboeuf --- kernel/livepatch/core.c | 25 ++++--------------------- kernel/livepatch/transition.c | 3 +++ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 790dc10..e572523 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -352,6 +352,9 @@ static int __klp_enable_patch(struct klp_patch *patch) !list_prev_entry(patch, list)->enabled) return -EBUSY; + if (!try_module_get(patch->mod)) + return -ENODEV; + pr_notice_once("tainting kernel with TAINT_LIVEPATCH\n"); add_taint(TAINT_LIVEPATCH, LOCKDEP_STILL_OK); @@ -497,10 +500,6 @@ static struct attribute *klp_patch_attrs[] = { static void klp_kobj_release_patch(struct kobject *kobj) { - /* - * Once we have a consistency model we'll need to module_put() the - * patch module here. See klp_register_patch() for more details. - */ } static struct kobj_type klp_ktype_patch = { @@ -715,29 +714,13 @@ EXPORT_SYMBOL_GPL(klp_unregister_patch); */ int klp_register_patch(struct klp_patch *patch) { - int ret; - if (!klp_initialized()) return -ENODEV; if (!patch || !patch->mod) return -EINVAL; - /* - * A reference is taken on the patch module to prevent it from being - * unloaded. Right now, we don't allow patch modules to unload since - * there is currently no method to determine if a thread is still - * running in the patched code contained in the patch module once - * the ftrace registration is successful. - */ - if (!try_module_get(patch->mod)) - return -ENODEV; - - ret = klp_init_patch(patch); - if (ret) - module_put(patch->mod); - - return ret; + return klp_init_patch(patch); } EXPORT_SYMBOL_GPL(klp_register_patch); diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index 2630296..20fafd2 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -54,6 +54,9 @@ void klp_complete_transition(void) for (func = obj->funcs; func->old_name; func++) func->transition = 0; + if (klp_universe_goal == KLP_UNIVERSE_OLD) + module_put(klp_transition_patch->mod); + klp_transition_patch = NULL; } -- 2.1.0 -- 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/