public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: [for-linus][PATCH 22/27] arm: kprobes: Make space for instruction pointer on stack
Date: Tue, 05 Oct 2021 09:57:55 -0400	[thread overview]
Message-ID: <20211005135829.626535781@goodmis.org> (raw)
In-Reply-To: 20211005135733.485175654@goodmis.org

From: Masami Hiramatsu <mhiramat@kernel.org>

Since arm's __kretprobe_trampoline() saves partial 'pt_regs' on the
stack, 'regs->ARM_pc' (instruction pointer) is not accessible from
the kretprobe handler. This means if instruction_pointer_set() is
used from kretprobe handler, it will break the data on the stack.

Make space for instruction pointer (ARM_pc) on the stack in the
__kretprobe_trampoline() for fixing this problem.

Link: https://lkml.kernel.org/r/163163052262.489837.10327621053231461255.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 arch/arm/probes/kprobes/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
index 67ce7eb8f285..95f23b47ba27 100644
--- a/arch/arm/probes/kprobes/core.c
+++ b/arch/arm/probes/kprobes/core.c
@@ -376,11 +376,13 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
 void __naked __kprobes __kretprobe_trampoline(void)
 {
 	__asm__ __volatile__ (
+		"sub	sp, sp, #16		\n\t"
 		"stmdb	sp!, {r0 - r11}		\n\t"
 		"mov	r0, sp			\n\t"
 		"bl	trampoline_handler	\n\t"
 		"mov	lr, r0			\n\t"
 		"ldmia	sp!, {r0 - r11}		\n\t"
+		"add	sp, sp, #16		\n\t"
 #ifdef CONFIG_THUMB2_KERNEL
 		"bx	lr			\n\t"
 #else
-- 
2.32.0

  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 ` [for-linus][PATCH 19/27] x86/kprobes: Add UNWIND_HINT_FUNC on kretprobe_trampoline() Steven Rostedt
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 ` Steven Rostedt [this message]
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.626535781@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --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