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>,
	Josh Poimboeuf <jpoimboe@redhat.com>, X86 ML <x86@kernel.org>,
	Daniel Xu <dxu@dxuuu.xyz>, Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Abhishek Sagar <sagar.abhishek@gmail.com>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Paul McKenney <paulmck@kernel.org>,
	stable@vger.kernel.org, Masami Hiramatsu <mhiramat@kernel.org>
Subject: [for-linus][PATCH 12/27] ia64: kprobes: Fix to pass correct trampoline address to the handler
Date: Tue, 05 Oct 2021 09:57:45 -0400	[thread overview]
Message-ID: <20211005135827.746867602@goodmis.org> (raw)
In-Reply-To: 20211005135733.485175654@goodmis.org

From: Masami Hiramatsu <mhiramat@kernel.org>

The following commit:

   Commit e792ff804f49 ("ia64: kprobes: Use generic kretprobe trampoline handler")

Passed the wrong trampoline address to __kretprobe_trampoline_handler(): it
passes the descriptor address instead of function entry address.

Pass the right parameter.

Also use correct symbol dereference function to get the function address
from 'kretprobe_trampoline' - an IA64 special.

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

Fixes: e792ff804f49 ("ia64: kprobes: Use generic kretprobe trampoline handler")
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: X86 ML <x86@kernel.org>
Cc: Daniel Xu <dxu@dxuuu.xyz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Abhishek Sagar <sagar.abhishek@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Paul McKenney <paulmck@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 arch/ia64/kernel/kprobes.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 441ed04b1037..d4048518a1d7 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -398,7 +398,8 @@ static void kretprobe_trampoline(void)
 
 int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
 {
-	regs->cr_iip = __kretprobe_trampoline_handler(regs, kretprobe_trampoline, NULL);
+	regs->cr_iip = __kretprobe_trampoline_handler(regs,
+		dereference_function_descriptor(kretprobe_trampoline), NULL);
 	/*
 	 * By returning a non-zero value, we are telling
 	 * kprobe_handler() that we don't want the post_handler
@@ -414,7 +415,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
 	ri->fp = NULL;
 
 	/* Replace the return addr with trampoline addr */
-	regs->b0 = ((struct fnptr *)kretprobe_trampoline)->ip;
+	regs->b0 = (unsigned long)dereference_function_descriptor(kretprobe_trampoline);
 }
 
 /* Check the instruction in the slot is break */
@@ -902,14 +903,14 @@ static struct kprobe trampoline_p = {
 int __init arch_init_kprobes(void)
 {
 	trampoline_p.addr =
-		(kprobe_opcode_t *)((struct fnptr *)kretprobe_trampoline)->ip;
+		dereference_function_descriptor(kretprobe_trampoline);
 	return register_kprobe(&trampoline_p);
 }
 
 int __kprobes arch_trampoline_kprobe(struct kprobe *p)
 {
 	if (p->addr ==
-		(kprobe_opcode_t *)((struct fnptr *)kretprobe_trampoline)->ip)
+		dereference_function_descriptor(kretprobe_trampoline))
 		return 1;
 
 	return 0;
-- 
2.32.0

  parent reply	other threads:[~2021-10-05 14:01 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 ` Steven Rostedt [this message]
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 ` [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=20211005135827.746867602@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bp@alien8.de \
    --cc=dxu@dxuuu.xyz \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sagar.abhishek@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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