linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/kprobes: Use probe_address() to read instructions
@ 2020-02-24 18:02 Christophe Leroy
  2020-06-09  5:28 ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy @ 2020-02-24 18:02 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, naveen.n.rao
  Cc: linux-kernel, linuxppc-dev

In order to avoid Oopses, use probe_address() to read the
instruction at the address where the trap happened.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/kprobes.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 84567406b53d..a35320b79e16 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -276,14 +276,18 @@ int kprobe_handler(struct pt_regs *regs)
 
 	p = get_kprobe(addr);
 	if (!p) {
-		if (*addr != BREAKPOINT_INSTRUCTION) {
+		unsigned int instr;
+
+		if (probe_kernel_address(addr, instr))
+			goto no_kprobe;
+
+		if (instr != BREAKPOINT_INSTRUCTION) {
 			/*
 			 * PowerPC has multiple variants of the "trap"
 			 * instruction. If the current instruction is a
 			 * trap variant, it could belong to someone else
 			 */
-			kprobe_opcode_t cur_insn = *addr;
-			if (is_trap(cur_insn))
+			if (is_trap(instr))
 				goto no_kprobe;
 			/*
 			 * The breakpoint instruction was removed right
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/kprobes: Use probe_address() to read instructions
  2020-02-24 18:02 [PATCH] powerpc/kprobes: Use probe_address() to read instructions Christophe Leroy
@ 2020-06-09  5:28 ` Michael Ellerman
  2020-06-09  5:53   ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2020-06-09  5:28 UTC (permalink / raw)
  To: Christophe Leroy, Paul Mackerras, Benjamin Herrenschmidt,
	Michael Ellerman, naveen.n.rao
  Cc: linuxppc-dev, linux-kernel

On Mon, 24 Feb 2020 18:02:10 +0000 (UTC), Christophe Leroy wrote:
> In order to avoid Oopses, use probe_address() to read the
> instruction at the address where the trap happened.

Applied to powerpc/next.

[1/1] powerpc/kprobes: Use probe_address() to read instructions
      https://git.kernel.org/powerpc/c/9ed5df69b79a22b40b20bc2132ba2495708b19c4

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/kprobes: Use probe_address() to read instructions
  2020-06-09  5:28 ` Michael Ellerman
@ 2020-06-09  5:53   ` Christoph Hellwig
  2020-06-10 10:12     ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2020-06-09  5:53 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Christophe Leroy, Paul Mackerras, Benjamin Herrenschmidt,
	Michael Ellerman, naveen.n.rao, linuxppc-dev, linux-kernel

On Tue, Jun 09, 2020 at 03:28:38PM +1000, Michael Ellerman wrote:
> On Mon, 24 Feb 2020 18:02:10 +0000 (UTC), Christophe Leroy wrote:
> > In order to avoid Oopses, use probe_address() to read the
> > instruction at the address where the trap happened.
> 
> Applied to powerpc/next.
> 
> [1/1] powerpc/kprobes: Use probe_address() to read instructions
>       https://git.kernel.org/powerpc/c/9ed5df69b79a22b40b20bc2132ba2495708b19c4

probe_addresss has been renamed to get_kernel_nofault in the -mm
queue that Andrew sent off to Linus last night.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/kprobes: Use probe_address() to read instructions
  2020-06-09  5:53   ` Christoph Hellwig
@ 2020-06-10 10:12     ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2020-06-10 10:12 UTC (permalink / raw)
  To: Christoph Hellwig, Michael Ellerman
  Cc: Christophe Leroy, Paul Mackerras, Benjamin Herrenschmidt,
	naveen.n.rao, linuxppc-dev, linux-kernel

Christoph Hellwig <hch@infradead.org> writes:
> On Tue, Jun 09, 2020 at 03:28:38PM +1000, Michael Ellerman wrote:
>> On Mon, 24 Feb 2020 18:02:10 +0000 (UTC), Christophe Leroy wrote:
>> > In order to avoid Oopses, use probe_address() to read the
>> > instruction at the address where the trap happened.
>> 
>> Applied to powerpc/next.
>> 
>> [1/1] powerpc/kprobes: Use probe_address() to read instructions
>>       https://git.kernel.org/powerpc/c/9ed5df69b79a22b40b20bc2132ba2495708b19c4
>
> probe_addresss has been renamed to get_kernel_nofault in the -mm
> queue that Andrew sent off to Linus last night.

That commit above is actually already in mainline, I was just _really_
behind on sending the patch notifications.

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-10 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 18:02 [PATCH] powerpc/kprobes: Use probe_address() to read instructions Christophe Leroy
2020-06-09  5:28 ` Michael Ellerman
2020-06-09  5:53   ` Christoph Hellwig
2020-06-10 10:12     ` Michael Ellerman

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).