diff options
author | Josh Poimboeuf <jpoimboe@redhat.com> | 2017-10-03 09:51:43 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-10-03 13:11:27 -0400 |
commit | ee213fc72fd67d0988525af501534f4cb924d1e9 (patch) | |
tree | 707cf46233eba22b0cfaf0468cb2f50787d0d2dd | |
parent | 9e66317d3c92ddaab330c125dfe9d06eee268aff (diff) |
kprobes/x86: Set up frame pointer in kprobe trampoline
Richard Weinberger saw an unwinder warning when running bcc's opensnoop:
WARNING: kernel stack frame pointer at ffff99ef4076bea0 in opensnoop:2008 has bad value 0000000000000008
unwind stack type:0 next_sp: (null) mask:0x2 graph_idx:0
...
ffff99ef4076be88: ffff99ef4076bea0 (0xffff99ef4076bea0)
ffff99ef4076be90: ffffffffac442721 (optimized_callback +0x81/0x90)
...
A lockdep stack trace was initiated from inside a kprobe handler, when
the unwinder noticed a bad frame pointer on the stack. The bad frame
pointer is related to the fact that the kprobe optprobe trampoline
doesn't save the frame pointer before calling into optimized_callback().
Reported-and-tested-by: Richard Weinberger <richard@sigma-star.at>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David S . Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/7aef2f8ecd75c2f505ef9b80490412262cf4a44c.1507038547.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/kprobes/common.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/x86/kernel/kprobes/common.h b/arch/x86/kernel/kprobes/common.h index db2182d63ed0..3fc0f9a794cb 100644 --- a/arch/x86/kernel/kprobes/common.h +++ b/arch/x86/kernel/kprobes/common.h | |||
@@ -3,6 +3,15 @@ | |||
3 | 3 | ||
4 | /* Kprobes and Optprobes common header */ | 4 | /* Kprobes and Optprobes common header */ |
5 | 5 | ||
6 | #include <asm/asm.h> | ||
7 | |||
8 | #ifdef CONFIG_FRAME_POINTER | ||
9 | # define SAVE_RBP_STRING " push %" _ASM_BP "\n" \ | ||
10 | " mov %" _ASM_SP ", %" _ASM_BP "\n" | ||
11 | #else | ||
12 | # define SAVE_RBP_STRING " push %" _ASM_BP "\n" | ||
13 | #endif | ||
14 | |||
6 | #ifdef CONFIG_X86_64 | 15 | #ifdef CONFIG_X86_64 |
7 | #define SAVE_REGS_STRING \ | 16 | #define SAVE_REGS_STRING \ |
8 | /* Skip cs, ip, orig_ax. */ \ | 17 | /* Skip cs, ip, orig_ax. */ \ |
@@ -17,7 +26,7 @@ | |||
17 | " pushq %r10\n" \ | 26 | " pushq %r10\n" \ |
18 | " pushq %r11\n" \ | 27 | " pushq %r11\n" \ |
19 | " pushq %rbx\n" \ | 28 | " pushq %rbx\n" \ |
20 | " pushq %rbp\n" \ | 29 | SAVE_RBP_STRING \ |
21 | " pushq %r12\n" \ | 30 | " pushq %r12\n" \ |
22 | " pushq %r13\n" \ | 31 | " pushq %r13\n" \ |
23 | " pushq %r14\n" \ | 32 | " pushq %r14\n" \ |
@@ -48,7 +57,7 @@ | |||
48 | " pushl %es\n" \ | 57 | " pushl %es\n" \ |
49 | " pushl %ds\n" \ | 58 | " pushl %ds\n" \ |
50 | " pushl %eax\n" \ | 59 | " pushl %eax\n" \ |
51 | " pushl %ebp\n" \ | 60 | SAVE_RBP_STRING \ |
52 | " pushl %edi\n" \ | 61 | " pushl %edi\n" \ |
53 | " pushl %esi\n" \ | 62 | " pushl %esi\n" \ |
54 | " pushl %edx\n" \ | 63 | " pushl %edx\n" \ |