Commit ef0d5b91 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'objtool-urgent-2020-05-17' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 stack unwinding fix from Thomas Gleixner:
 "A single bugfix for the ORC unwinder to ensure that the error flag
  which tells the unwinding code whether a stack trace can be trusted or
  not is always set correctly.

  This was messed up by a couple of changes in the recent past"

* tag 'objtool-urgent-2020-05-17' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/unwind/orc: Fix error handling in __unwind_start()
parents 43567139 71c95825
...@@ -617,23 +617,23 @@ EXPORT_SYMBOL_GPL(unwind_next_frame); ...@@ -617,23 +617,23 @@ EXPORT_SYMBOL_GPL(unwind_next_frame);
void __unwind_start(struct unwind_state *state, struct task_struct *task, void __unwind_start(struct unwind_state *state, struct task_struct *task,
struct pt_regs *regs, unsigned long *first_frame) struct pt_regs *regs, unsigned long *first_frame)
{ {
if (!orc_init)
goto done;
memset(state, 0, sizeof(*state)); memset(state, 0, sizeof(*state));
state->task = task; state->task = task;
if (!orc_init)
goto err;
/* /*
* Refuse to unwind the stack of a task while it's executing on another * Refuse to unwind the stack of a task while it's executing on another
* CPU. This check is racy, but that's ok: the unwinder has other * CPU. This check is racy, but that's ok: the unwinder has other
* checks to prevent it from going off the rails. * checks to prevent it from going off the rails.
*/ */
if (task_on_another_cpu(task)) if (task_on_another_cpu(task))
goto done; goto err;
if (regs) { if (regs) {
if (user_mode(regs)) if (user_mode(regs))
goto done; goto the_end;
state->ip = regs->ip; state->ip = regs->ip;
state->sp = regs->sp; state->sp = regs->sp;
...@@ -666,6 +666,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, ...@@ -666,6 +666,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
* generate some kind of backtrace if this happens. * generate some kind of backtrace if this happens.
*/ */
void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp); void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp);
state->error = true;
if (get_stack_info(next_page, state->task, &state->stack_info, if (get_stack_info(next_page, state->task, &state->stack_info,
&state->stack_mask)) &state->stack_mask))
return; return;
...@@ -691,8 +692,9 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, ...@@ -691,8 +692,9 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
return; return;
done: err:
state->error = true;
the_end:
state->stack_info.type = STACK_TYPE_UNKNOWN; state->stack_info.type = STACK_TYPE_UNKNOWN;
return;
} }
EXPORT_SYMBOL_GPL(__unwind_start); EXPORT_SYMBOL_GPL(__unwind_start);
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