提交 9027a5e5 编写于 作者: C Cheng Jian 提交者: Xie XiuQi

livepatch/arm64: fix current backtracking in klp_check_calltrace

hulk inclusion
category: bugfix
bugzilla: 13277
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: NLi Bin <huawei.libin@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 e7e6a881
......@@ -110,8 +110,32 @@ int klp_check_calltrace(struct klp_patch *patch, int enable)
};
for_each_process_thread(g, t) {
frame.fp = thread_saved_fp(t);
frame.pc = thread_saved_pc(t);
/*
* Handle the current carefully on each CPUs, we shouldn't
* use saved FP and PC when backtrace current. It's difficult
* to backtrack other CPU currents here. But fortunately,
* all CPUs will stay in this function, so the current's
* backtrace is so similar
*/
if (t == current) {
/* current on this CPU */
frame.fp = (unsigned long)__builtin_frame_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.pc = thread_saved_pc(t);
}
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = t->curr_ret_stack;
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册