hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7ZH67 CVE: NA
--------------------------------
After patch being enabled, the first few instructions would be modified to jump to the new function, then callers of old function would jump to new function but always through the old function.
Therefore when enabling a new patch or disable a patch on the old function, we should always consider that old function is running. Otherwise, there may be situations where old functions are being modified before jumping to new function and cause issues.
Signed-off-by: Zheng Yejian zhengyejian1@huawei.com --- arch/arm64/kernel/livepatch.c | 6 ++++++ arch/x86/kernel/livepatch.c | 3 +++ 2 files changed, 9 insertions(+)
diff --git a/arch/arm64/kernel/livepatch.c b/arch/arm64/kernel/livepatch.c index 235e6f8b6719..4bb27fc703fb 100644 --- a/arch/arm64/kernel/livepatch.c +++ b/arch/arm64/kernel/livepatch.c @@ -144,6 +144,12 @@ static int klp_check_activeness_func(struct stackframe *frame, void *data) func_size, func_name); if (args->ret) return args->ret; + if (func_addr != func->old_addr) { + args->ret = klp_compare_address(frame->pc, func->old_addr, + func->old_size, func_name); + if (args->ret) + return args->ret; + } } }
diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c index 785bba03b77f..7bc8325790a1 100644 --- a/arch/x86/kernel/livepatch.c +++ b/arch/x86/kernel/livepatch.c @@ -166,6 +166,9 @@ static int klp_check_stack_func(struct klp_func *func, if (klp_compare_address(address, func_addr, func_size, func_name)) return -EAGAIN; + if (func_addr != func->old_addr && + klp_compare_address(address, func->old_addr, func->old_size, func_name)) + return -EAGAIN; }
return 0;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/2072 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/L...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/2072 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/L...