[PATCH] powerpc/kprobes: Use probe_address() to read instructions

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE2256d LANDED

Landed in mainline as 9ed5df69b79a on 2020-06-02.

4 messages, 4 authors, 2020-06-10 · open the first message on its own page

[PATCH] powerpc/kprobes: Use probe_address() to read instructions

From: Christophe Leroy <hidden>
Date: 2020-02-24 18:02:15

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

Signed-off-by: Christophe Leroy <redacted>
---
 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

Re: [PATCH] powerpc/kprobes: Use probe_address() to read instructions

From: Michael Ellerman <hidden>
Date: 2020-06-09 05:28:46

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

Re: [PATCH] powerpc/kprobes: Use probe_address() to read instructions

From: Christoph Hellwig <hch@infradead.org>
Date: 2020-06-09 05:53:52

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:
quoted
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.

Re: [PATCH] powerpc/kprobes: Use probe_address() to read instructions

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2020-06-10 10:12:18

Christoph Hellwig [off-list ref] writes:
On Tue, Jun 09, 2020 at 03:28:38PM +1000, Michael Ellerman wrote:
quoted
On Mon, 24 Feb 2020 18:02:10 +0000 (UTC), Christophe Leroy wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help