From 6881c07f6c24a6286e9847346e1397ae6bee0720 Mon Sep 17 00:00:00 2001 From: Evgenii Shatokhin Date: Mon, 1 Jul 2019 12:44:17 +0300 Subject: [PATCH] kmod/core: pass 'replace' flag to kpatch_apply_patch() Make kpatch_apply_patch() aware of whether the patch should replace other patches. This will be used by subsequent fixes. Signed-off-by: Evgenii Shatokhin --- kmod/core/core.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kmod/core/core.c b/kmod/core/core.c index a91d417..3bfebe4 100644 --- a/kmod/core/core.c +++ b/kmod/core/core.c @@ -83,6 +83,11 @@ struct kpatch_kallsyms_args { unsigned long pos; }; +struct kpatch_apply_patch_args { + struct kpatch_module *kpmod; + bool replace; +}; + /* this is a double loop, use goto instead of break */ #define do_for_each_linked_func(kpmod, func) { \ struct kpatch_object *_object; \ @@ -350,11 +355,14 @@ static inline void post_unpatch_callback(struct kpatch_object *object) /* Called from stop_machine */ static int kpatch_apply_patch(void *data) { - struct kpatch_module *kpmod = data; + struct kpatch_apply_patch_args *args = data; + struct kpatch_module *kpmod; struct kpatch_func *func; struct kpatch_object *object; int ret; + kpmod = args->kpmod; + ret = kpatch_verify_activeness_safety(kpmod); if (ret) { kpatch_state_finish(KPATCH_STATE_FAILURE); @@ -980,6 +988,11 @@ int kpatch_register(struct kpatch_module *kpmod, bool replace) struct kpatch_object *object, *object_err = NULL; struct kpatch_func *func; + struct kpatch_apply_patch_args args = { + .kpmod = kpmod, + .replace = replace, + }; + if (!kpmod->mod || list_empty(&kpmod->objects)) return -EINVAL; @@ -1031,7 +1044,7 @@ int kpatch_register(struct kpatch_module *kpmod, bool replace) * Idle the CPUs, verify activeness safety, and atomically make the new * functions visible to the ftrace handler. */ - ret = stop_machine(kpatch_apply_patch, kpmod, NULL); + ret = stop_machine(kpatch_apply_patch, &args, NULL); /* * For the replace case, remove any obsolete funcs from the hash and