Commit 5d1ceb39 authored by Peter Zijlstra's avatar Peter Zijlstra

x86: Fix __get_wchan() for !STACKTRACE

Use asm/unwind.h to implement wchan, since we cannot always rely on
STACKTRACE=y.

Fixes: bc9bbb81 ("x86: Fix get_wchan() to support the ORC unwinder")
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20211022152104.137058575@infradead.org
parent 55409ac5
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <asm/io_bitmap.h> #include <asm/io_bitmap.h>
#include <asm/proto.h> #include <asm/proto.h>
#include <asm/frame.h> #include <asm/frame.h>
#include <asm/unwind.h>
#include "process.h" #include "process.h"
...@@ -944,10 +945,20 @@ unsigned long arch_randomize_brk(struct mm_struct *mm) ...@@ -944,10 +945,20 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
*/ */
unsigned long __get_wchan(struct task_struct *p) unsigned long __get_wchan(struct task_struct *p)
{ {
unsigned long entry = 0; struct unwind_state state;
unsigned long addr = 0;
stack_trace_save_tsk(p, &entry, 1, 0); for (unwind_start(&state, p, NULL, NULL); !unwind_done(&state);
return entry; unwind_next_frame(&state)) {
addr = unwind_get_return_address(&state);
if (!addr)
break;
if (in_sched_functions(addr))
continue;
break;
}
return addr;
} }
long do_arch_prctl_common(struct task_struct *task, int option, long do_arch_prctl_common(struct task_struct *task, int option,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment