Skip to content

Commit 55f856e

Browse files
jpoimboeingomolnar
authored andcommitted
x86/unwind: Fix guess-unwinder regression
My attempt at fixing some KASAN false positive warnings was rather brain dead, and it broke the guess unwinder. With frame pointers disabled, /proc/<pid>/stack is broken: # cat /proc/1/stack [<ffffffffffffffff>] 0xffffffffffffffff Restore the code flow to more closely resemble its previous state, while still using READ_ONCE_NOCHECK() macros to silence KASAN false positives. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: c2d75e0 ("x86/unwind: Prevent KASAN false positive warnings in guess unwinder") Link: http://lkml.kernel.org/r/b824f92c2c22eca5ec95ac56bd2a7c84cf0b9df9.1480309971.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent adee870 commit 55f856e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

arch/x86/kernel/unwind_guess.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
unsigned long unwind_get_return_address(struct unwind_state *state)
99
{
10-
unsigned long addr = READ_ONCE_NOCHECK(*state->sp);
10+
unsigned long addr;
1111

1212
if (unwind_done(state))
1313
return 0;
1414

15+
addr = READ_ONCE_NOCHECK(*state->sp);
16+
1517
return ftrace_graph_ret_addr(state->task, &state->graph_idx,
1618
addr, state->sp);
1719
}
@@ -25,11 +27,12 @@ bool unwind_next_frame(struct unwind_state *state)
2527
return false;
2628

2729
do {
28-
unsigned long addr = READ_ONCE_NOCHECK(*state->sp);
30+
for (state->sp++; state->sp < info->end; state->sp++) {
31+
unsigned long addr = READ_ONCE_NOCHECK(*state->sp);
2932

30-
for (state->sp++; state->sp < info->end; state->sp++)
3133
if (__kernel_text_address(addr))
3234
return true;
35+
}
3336

3437
state->sp = info->next_sp;
3538

0 commit comments

Comments
 (0)