[PATCH] powerpc/kprobes: Fix handling of instruction emulation on probe re-entry

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

STALE3372d

2 messages, 2 authors, 2017-05-17 · open the first message on its own page

[PATCH] powerpc/kprobes: Fix handling of instruction emulation on probe re-entry

From: Naveen N. Rao <hidden>
Date: 2017-05-15 18:11:23

Commit 22d8b3dec214c ("powerpc/kprobes: Emulate instructions on kprobe
handler re-entry") enabled emulating instructions on kprobe re-entry,
rather than single-stepping always. However, we didn't update the single
stepping code to only be run if the emulation fails. Also, we missed
re-enabling preemption if the instruction emulation was successful. Fix
those issues.

Fixes: 22d8b3dec214c ("powerpc/kprobes: Emulate instructions on kprobe
handler re-entry")

Signed-off-by: Naveen N. Rao <redacted>
---
Michael,
Sorry for letting this slip through. Between when I first wrote the
above commit to when I posted it, there was an issue with a rebase that
resulted in slightly different code getting through (in other words, I
messed up the rebase resolution). I have now tested this version and
verified that this works properly.

Thanks,
Naveen 

 arch/powerpc/kernel/kprobes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 1ebeb8c482db..793c3385dfaa 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -299,16 +299,17 @@ int kprobe_handler(struct pt_regs *regs)
 			save_previous_kprobe(kcb);
 			set_current_kprobe(p, regs, kcb);
 			kprobes_inc_nmissed_count(p);
-			prepare_singlestep(p, regs);
 			kcb->kprobe_status = KPROBE_REENTER;
 			if (p->ainsn.boostable >= 0) {
 				ret = try_to_emulate(p, regs);
 
 				if (ret > 0) {
 					restore_previous_kprobe(kcb);
+					preempt_enable_no_resched();
 					return 1;
 				}
 			}
+			prepare_singlestep(p, regs);
 			return 1;
 		} else {
 			if (*addr != BREAKPOINT_INSTRUCTION) {
-- 
2.12.2

Re: powerpc/kprobes: Fix handling of instruction emulation on probe re-entry

From: Michael Ellerman <hidden>
Date: 2017-05-17 09:34:38

On Mon, 2017-05-15 at 18:10:05 UTC, "Naveen N. Rao" wrote:
Commit 22d8b3dec214c ("powerpc/kprobes: Emulate instructions on kprobe
handler re-entry") enabled emulating instructions on kprobe re-entry,
rather than single-stepping always. However, we didn't update the single
stepping code to only be run if the emulation fails. Also, we missed
re-enabling preemption if the instruction emulation was successful. Fix
those issues.

Fixes: 22d8b3dec214c ("powerpc/kprobes: Emulate instructions on kprobe
handler re-entry")

Signed-off-by: Naveen N. Rao <redacted>
Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/d04c02f8aa96d82e4cbe783f85a820

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