提交 26c48dbf 编写于 作者: L Lexi Shao 提交者: Zheng Zengkai

livepatch/ppc64: Ignore the first frame when checking stack

rtos inclusion
category: bugfix
bugzilla: 42399/46793/51924
CVE: NA

----------------------------------------

According to function _switch in entry_32/64.S, for non-current and
not-in-interrupt task, the LR is saved in the LR position in the 2nd
frame. The content in LR position in the 1st frame is not filled, so
it is left by previous stack frames and may be an address in a kernel
function, resulting in failure in applying a kernel patch even when the
target function is not actually in stack.

Therefore, we should ignore the first frame to get a more reliable
backtrace.
Signed-off-by: NLexi Shao <shaolexi@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Signed-off-by: NDong Kai <dongkai11@huawei.com>
Signed-off-by: NYe Weihua <yeweihua4@huawei.com>
Reviewed-by: NYang Jihong <yangjihong1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 e8a5fda2
......@@ -304,7 +304,17 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
*/
continue;
} else {
stack = (unsigned long *)t->thread.ksp;
/*
* Skip the first frame since it does not contain lr
* at notmal position and nip is store ind the lr
* position in the second frame.
* See arch/powerpc/kernel/entry_64.S _switch .
*/
unsigned long s = *(unsigned long *)t->thread.ksp;
if (!validate_sp(s, t, STACK_FRAME_OVERHEAD))
continue;
stack = (unsigned long *)s;
}
frame.sp = (unsigned long)stack;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册