Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8ORHJ
--------------------------------
Replacing is an optimization for livepatching based on ftrace, the wo_ftrace solution do not support it.
Signed-off-by: Zheng Yejian zhengyejian1@huawei.com --- kernel/livepatch/core.c | 8 ++++++++ kernel/livepatch/patch.c | 2 ++ 2 files changed, 10 insertions(+)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 8768ec1bddf3..5906a8835910 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1156,6 +1156,9 @@ static void klp_init_func_early(struct klp_object *obj, kobject_init(&func->kobj, &klp_ktype_func); list_add_tail(&func->node, &obj->func_list); func->func_node = NULL; +#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY + func->nop = false; +#endif }
static void klp_init_object_early(struct klp_patch *patch, @@ -1166,6 +1169,7 @@ static void klp_init_object_early(struct klp_patch *patch, list_add_tail(&obj->node, &patch->obj_list); #ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY obj->mod = NULL; + obj->dynamic = false; #endif }
@@ -1246,6 +1250,10 @@ static int klp_init_patch(struct klp_patch *patch) return ret;
if (patch->replace) { +#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY + pr_err("Replacing is not supported\n"); + return -EINVAL; +#endif ret = klp_add_nops(patch); if (ret) return ret; diff --git a/kernel/livepatch/patch.c b/kernel/livepatch/patch.c index bea6c5d0af94..df0c487a04fd 100644 --- a/kernel/livepatch/patch.c +++ b/kernel/livepatch/patch.c @@ -315,7 +315,9 @@ int klp_patch_object(struct klp_object *obj, bool rollback) if (obj->patched) return 0;
+ WARN_ON(obj->dynamic); klp_for_each_func(obj, func) { + WARN_ON(func->nop); ret = klp_patch_func(func); if (ret && klp_need_rollback(ret, rollback)) { klp_unpatch_object(obj);