提交 9ce4e2cd 编写于 作者: C Cheng Jian 提交者: Zheng Zengkai

livepatch/arm: Fix current backtracking in klp_check_calltrace

euler inclusion
category: bugfix
bugzilla: 51923
CVE: NA

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

We through stack checking to ensure the consistency of livepatch.
Task blocked in __switch_to when switch out, thread_saved_fs/pc
store the FP and PC when switching, it can be useful when tracing
blocked threads. For running task, __builtin_frame_address can be
used, but it's difficult to backtracking the running task on other
CPUs.

Fortunately, all CPUs will stay in this function, the current's
backtrace is so similar. so just backtracking the current on this
CPU, skip the current of other CPUs.
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: Nzhangyi (F) <yi.zhang@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>
上级 2fa9f353
...@@ -93,9 +93,29 @@ int klp_check_calltrace(struct klp_patch *patch, int enable) ...@@ -93,9 +93,29 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
}; };
for_each_process_thread(g, t) { for_each_process_thread(g, t) {
frame.fp = thread_saved_fp(t); if (t == current) {
frame.sp = thread_saved_sp(t); frame.fp = (unsigned long)__builtin_frame_address(0);
frame.pc = thread_saved_pc(t); frame.sp = current_stack_pointer;
frame.lr = (unsigned long)__builtin_return_address(0);
frame.pc = (unsigned long)klp_check_calltrace;
} else if (strncmp(t->comm, "migration/", 10) == 0) {
/*
* current on other CPU
* we call this in stop_machine, so the current
* of each CPUs is mirgation, just compare the
* task_comm here, because we can't get the
* cpu_curr(task_cpu(t))). This assumes that no
* other thread will pretend to be a stopper via
* task_comm.
*/
continue;
} else {
frame.fp = thread_saved_fp(t);
frame.sp = thread_saved_sp(t);
frame.lr = 0; /* recovered from the stack */
frame.pc = thread_saved_pc(t);
}
walk_stackframe(&frame, klp_check_activeness_func, &args); walk_stackframe(&frame, klp_check_activeness_func, &args);
if (args.ret) { if (args.ret) {
ret = args.ret; ret = args.ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册