From: Masami Hiramatsu <mhiramat@kernel.org>
To: peterz@infradead.org
Cc: Eddy Wu <Eddy_Wu@trendmicro.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
"David S . Miller" <davem@davemloft.net>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
linux-arch@vger.kernel.org
Subject: Re: [RFC PATCH 03/14] arm: kprobes: Use generic kretprobe trampoline handler
Date: Thu, 27 Aug 2020 00:04:05 +0900 [thread overview]
Message-ID: <20200827000405.60aa815dbb6f1417dc9da867@kernel.org> (raw)
In-Reply-To: <20200826141025.GU35926@hirez.programming.kicks-ass.net>
On Wed, 26 Aug 2020 16:10:25 +0200
peterz@infradead.org wrote:
> On Wed, Aug 26, 2020 at 04:08:52PM +0200, peterz@infradead.org wrote:
> > On Wed, Aug 26, 2020 at 10:46:43PM +0900, Masami Hiramatsu wrote:
> > > static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
> > > {
> > > + return (void *)kretprobe_trampoline_handler(regs,
> > > + (unsigned long)&kretprobe_trampoline,
> > > + regs->ARM_fp);
> > > }
> >
> > Does it make sense to have the generic code have a weak
> > trampoline_handler() implemented like the above? It looks like a number
> > of architectures have this trivial variant and it seems pointless to
> > duplicate this.
>
> Argh, I replied to the wrong variant, I mean the one that uses
> kernel_stack_pointer(regs).
Would you mean using kernel_stack_pointer() for the frame_pointer?
Some arch will be OK, but others can not get the framepointer by that.
(that is because the stack layout is different on the function prologue
and returned address, e.g. x86...)
>
> Then the architecture only needs to implement kernel_stack_pointer() if
> there is nothing else to do.
There are 2 patterns of kretprobe trampoline handling, one is using
a kprobe which hooks the trampoline code. In this case, the
trampoline handler is a kprobe pre_handler. And another is not
using kprobe, but trampoline code saves (a part of)pt_regs and call
the trampoline handler. In this case the trampoline handler will get
the (maybe incomplete) pt_regs. Actually, arm kretprobe handler doesn't
save the sp register for some reason...
Thank you,
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2020-08-26 15:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 13:46 [RFC PATCH 00/14] kprobes: Unify kretprobe trampoline handlers Masami Hiramatsu
2020-08-26 13:46 ` [RFC PATCH 01/14] kprobes: Add generic kretprobe trampoline handler Masami Hiramatsu
2020-08-26 13:46 ` [RFC PATCH 02/14] x86/kprobes: Use " Masami Hiramatsu
2020-08-26 13:46 ` [RFC PATCH 03/14] arm: kprobes: " Masami Hiramatsu
2020-08-26 14:08 ` peterz
2020-08-26 14:10 ` peterz
2020-08-26 15:04 ` Masami Hiramatsu [this message]
2020-08-26 15:26 ` peterz
2020-08-26 13:46 ` [RFC PATCH 04/14] arm64: " Masami Hiramatsu
2020-08-26 13:47 ` [RFC PATCH 05/14] arc: " Masami Hiramatsu
2020-08-26 13:47 ` [RFC PATCH 06/14] csky: " Masami Hiramatsu
2020-08-26 13:47 ` [RFC PATCH 07/14] ia64: " Masami Hiramatsu
2020-08-26 13:47 ` [RFC PATCH 08/14] mips: " Masami Hiramatsu
2020-08-26 13:47 ` [RFC PATCH 09/14] parisc: " Masami Hiramatsu
2020-08-26 13:47 ` [RFC PATCH 10/14] powerpc: " Masami Hiramatsu
2020-08-26 13:48 ` [RFC PATCH 11/14] s390: " Masami Hiramatsu
2020-08-26 13:48 ` [RFC PATCH 12/14] sh: " Masami Hiramatsu
2020-08-26 13:48 ` [RFC PATCH 13/14] sparc: " Masami Hiramatsu
2020-08-26 13:48 ` [RFC PATCH 14/14] kprobes: Remove NMI context check Masami Hiramatsu
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=20200827000405.60aa815dbb6f1417dc9da867@kernel.org \
--to=mhiramat@kernel.org \
--cc=Eddy_Wu@trendmicro.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=naveen.n.rao@linux.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--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