提交 16f3032a 编写于 作者: S Song Liu 提交者: Yang Yingliang

perf/x86: Always store regs->ip in perf_callchain_kernel()

mainline inclusion
from mainline-5.2-rc7
commit 83f44ae0
category: bugfix
bugzilla: 35738
CVE: NA

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

The stacktrace_map_raw_tp BPF selftest is failing because the RIP saved by
perf_arch_fetch_caller_regs() isn't getting saved by perf_callchain_kernel().

This was broken by the following commit:

  d15d3568 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")

With that change, when starting with non-HW regs, the unwinder starts
with the current stack frame and unwinds until it passes up the frame
which called perf_arch_fetch_caller_regs().  So regs->ip needs to be
saved deliberately.

Fixes: d15d3568 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")
Signed-off-by: NSong Liu <songliubraving@fb.com>
Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Kairui Song <kasong@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Link: https://lkml.kernel.org/r/3975a298fa52b506fea32666d8ff6a13467eee6d.1561595111.git.jpoimboe@redhat.comSigned-off-by: NWei Li <liwei391@huawei.com>
Reviewed-by: NJian Cheng <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f20c4859
...@@ -2356,13 +2356,13 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re ...@@ -2356,13 +2356,13 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
return; return;
} }
if (perf_hw_regs(regs)) { if (perf_callchain_store(entry, regs->ip))
if (perf_callchain_store(entry, regs->ip)) return;
return;
if (perf_hw_regs(regs))
unwind_start(&state, current, regs, NULL); unwind_start(&state, current, regs, NULL);
} else { else
unwind_start(&state, current, NULL, (void *)regs->sp); unwind_start(&state, current, NULL, (void *)regs->sp);
}
for (; !unwind_done(&state); unwind_next_frame(&state)) { for (; !unwind_done(&state); unwind_next_frame(&state)) {
addr = unwind_get_return_address(&state); addr = unwind_get_return_address(&state);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册