From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>
Subject: [for-linus][PATCH 19/27] x86/kprobes: Add UNWIND_HINT_FUNC on kretprobe_trampoline()
Date: Tue, 05 Oct 2021 09:57:52 -0400 [thread overview]
Message-ID: <20211005135829.077894983@goodmis.org> (raw)
In-Reply-To: 20211005135733.485175654@goodmis.org
From: Josh Poimboeuf <jpoimboe@redhat.com>
Add UNWIND_HINT_FUNC on __kretprobe_trampoline() code so that ORC
information is generated on the __kretprobe_trampoline() correctly.
Also, this uses STACK_FRAME_NON_STANDARD_FP(), CONFIG_FRAME_POINTER-
-specific version of STACK_FRAME_NON_STANDARD().
Link: https://lkml.kernel.org/r/163163049242.489837.11970969750993364293.stgit@devnote2
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
arch/x86/include/asm/unwind_hints.h | 5 +++++
arch/x86/kernel/kprobes/core.c | 13 +++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/unwind_hints.h b/arch/x86/include/asm/unwind_hints.h
index 8e574c0afef8..8b33674288ea 100644
--- a/arch/x86/include/asm/unwind_hints.h
+++ b/arch/x86/include/asm/unwind_hints.h
@@ -52,6 +52,11 @@
UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=8 type=UNWIND_HINT_TYPE_FUNC
.endm
+#else
+
+#define UNWIND_HINT_FUNC \
+ UNWIND_HINT(ORC_REG_SP, 8, UNWIND_HINT_TYPE_FUNC, 0)
+
#endif /* __ASSEMBLY__ */
#endif /* _ASM_X86_UNWIND_HINTS_H */
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 79cd23dba5b5..d1436d7463fd 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -1025,6 +1025,7 @@ asm(
/* We don't bother saving the ss register */
#ifdef CONFIG_X86_64
" pushq %rsp\n"
+ UNWIND_HINT_FUNC
" pushfq\n"
SAVE_REGS_STRING
" movq %rsp, %rdi\n"
@@ -1035,6 +1036,7 @@ asm(
" popfq\n"
#else
" pushl %esp\n"
+ UNWIND_HINT_FUNC
" pushfl\n"
SAVE_REGS_STRING
" movl %esp, %eax\n"
@@ -1048,8 +1050,15 @@ asm(
".size __kretprobe_trampoline, .-__kretprobe_trampoline\n"
);
NOKPROBE_SYMBOL(__kretprobe_trampoline);
-STACK_FRAME_NON_STANDARD(__kretprobe_trampoline);
-
+/*
+ * __kretprobe_trampoline() skips updating frame pointer. The frame pointer
+ * saved in trampoline_handler() points to the real caller function's
+ * frame pointer. Thus the __kretprobe_trampoline() doesn't have a
+ * standard stack frame with CONFIG_FRAME_POINTER=y.
+ * Let's mark it non-standard function. Anyway, FP unwinder can correctly
+ * unwind without the hint.
+ */
+STACK_FRAME_NON_STANDARD_FP(__kretprobe_trampoline);
/*
* Called from __kretprobe_trampoline
--
2.32.0
next prev parent reply other threads:[~2021-10-05 14:02 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 13:57 [for-linus][PATCH 00/27] tracing: Updates for 5.16 Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 01/27] kprobes: Do not use local variable when creating debugfs file Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 02/27] kprobes: Use helper to parse boolean input from userspace Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 03/27] kprobe: Simplify prepare_kprobe() by dropping redundant version Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 04/27] csky: ftrace: Drop duplicate implementation of arch_check_ftrace_location() Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 05/27] kprobes: Make arch_check_ftrace_location static Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 06/27] kprobes: treewide: Cleanup the error messages for kprobes Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 07/27] kprobes: Fix coding style issues Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 08/27] kprobes: Use IS_ENABLED() instead of kprobes_built_in() Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 09/27] kprobes: Add assertions for required lock Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 10/27] kprobes: treewide: Use kprobe_opcode_t * for the code address in get_optimized_kprobe() Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 11/27] kprobes: Use bool type for functions which returns boolean value Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 12/27] ia64: kprobes: Fix to pass correct trampoline address to the handler Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 13/27] kprobes: treewide: Replace arch_deref_entry_point() with dereference_symbol_descriptor() Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 14/27] kprobes: treewide: Remove trampoline_address from kretprobe_trampoline_handler() Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 15/27] kprobes: treewide: Make it harder to refer kretprobe_trampoline directly Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 16/27] kprobes: Add kretprobe_find_ret_addr() for searching return address Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 17/27] objtool: Add frame-pointer-specific function ignore Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 18/27] objtool: Ignore unwind hints for ignored functions Steven Rostedt
2021-10-05 13:57 ` Steven Rostedt [this message]
2021-10-05 13:57 ` [for-linus][PATCH 20/27] ARC: Add instruction_pointer_set() API Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 21/27] ia64: " Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 22/27] arm: kprobes: Make space for instruction pointer on stack Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 23/27] kprobes: Enable stacktrace from pt_regs in kretprobe handler Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 24/27] x86/kprobes: Push a fake return address at kretprobe_trampoline Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 25/27] x86/unwind: Recover kretprobe trampoline entry Steven Rostedt
2021-10-05 13:57 ` [for-linus][PATCH 26/27] tracing: Show kretprobe unknown indicator only for kretprobe_trampoline Steven Rostedt
2021-10-05 13:58 ` [for-linus][PATCH 27/27] x86/kprobes: Fixup return address in generic trampoline handler Steven Rostedt
2021-10-05 15:00 ` [for-linus][PATCH 00/27] tracing: Updates for 5.16 Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211005135829.077894983@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).