hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8MGE6 CVE: NA
----------------------------------------
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 --- include/linux/livepatch.h | 2 +- kernel/livepatch/core.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h index b5ef9c2d8718..c71859c4824c 100644 --- a/include/linux/livepatch.h +++ b/include/linux/livepatch.h @@ -170,7 +170,7 @@ struct klp_patch { struct module *mod; struct klp_object *objs; struct klp_state *states; /* Not used in the solution without ftrace */ - bool replace; /* Not used in the solution without ftrace */ + bool replace; /* Not supported in the solution without ftrace */
/* internal */ struct list_head list; diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 72db3e79c303..fef672d7b4b6 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1037,13 +1037,16 @@ static int klp_init_patch(struct klp_patch *patch) if (ret) return ret;
-#ifdef CONFIG_LIVEPATCH_FTRACE if (patch->replace) { +#ifdef CONFIG_LIVEPATCH_FTRACE ret = klp_add_nops(patch); if (ret) return ret; - } +#else + pr_err("Replacing is not supported\n"); + return -EINVAL; #endif + }
klp_for_each_object(patch, obj) { ret = klp_init_object(patch, obj);