[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200117150323.21801-7-pmladek@suse.com>
Date: Fri, 17 Jan 2020 16:03:06 +0100
From: Petr Mladek <pmladek@...e.com>
To: Jiri Kosina <jikos@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Miroslav Benes <mbenes@...e.cz>
Cc: Joe Lawrence <joe.lawrence@...hat.com>,
Kamalesh Babulal <kamalesh@...ux.vnet.ibm.com>,
Nicolai Stange <nstange@...e.de>,
live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
Petr Mladek <pmladek@...e.com>
Subject: [POC 06/23] livepatch: Enable the livepatch submodule
The final step when loading livepatch module for livepatching a module
is to actually enable the livepatch.
The steps are exactly the same as in kmp_module_comming().
Note that there is no need to call klp_cleanup_module_patches_limited()
in the error path. klp_add_object() modifies only the single matching
struct klp_patch.
Signed-off-by: Petr Mladek <pmladek@...e.com>
---
kernel/livepatch/core.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 6c27b635e5a7..c21bd9ec2012 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -1011,6 +1011,28 @@ int klp_add_object(struct klp_object *obj)
goto err_free;
}
+ pr_notice("applying patch '%s' to loading module '%s'\n",
+ patch->obj->patch_name, obj->name);
+
+ ret = klp_pre_patch_callback(obj);
+ if (ret) {
+ pr_warn("pre-patch callback failed for object '%s'\n",
+ obj->name);
+ goto err_free;
+ }
+
+ ret = klp_patch_object(obj);
+ if (ret) {
+ pr_warn("failed to apply patch '%s' to module '%s' (%d)\n",
+ patch->obj->patch_name, obj->name, ret);
+
+ klp_post_unpatch_callback(obj);
+ goto err_free;
+ }
+
+ if (patch != klp_transition_patch)
+ klp_post_patch_callback(obj);
+
mutex_unlock(&klp_mutex);
return 0;
--
2.16.4
Powered by blists - more mailing lists