Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1580970

[BUGFIX PATCH V2 2/3] kprobes/arm: Skip single-stepping in recursing path if possible

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject [BUGFIX PATCH V2 2/3] kprobes/arm: Skip single-stepping in recursing path if possible
Date 2017-02-15 01:40 +0100
Message-ID <taVNw-wP-15@gated-at.bofh.it> (permalink)
References <taVDP-tw-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Kprobes/arm skips single-stepping (moreover handling the event)
if the conditional instruction must not be executed. This
also applies that rule when we hit a recursing kprobe, so
that the nmissed count isn't incremented in that case.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
---
 arch/arm/probes/kprobes/core.c |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
index 264fedb..84989ae 100644
--- a/arch/arm/probes/kprobes/core.c
+++ b/arch/arm/probes/kprobes/core.c
@@ -265,7 +265,15 @@ void __kprobes kprobe_handler(struct pt_regs *regs)
 #endif
 
 	if (p) {
-		if (cur) {
+		if (!p->ainsn.insn_check_cc(regs->ARM_cpsr)) {
+			/*
+			 * Probe hit but conditional execution check failed,
+			 * so just skip the instruction and continue as if
+			 * nothing had happened.
+			 * In this case, we can skip recursing check too.
+			 */
+			singlestep_skip(p, regs);
+		} else if (cur) {
 			/* Kprobe is pending, so we're recursing. */
 			switch (kcb->kprobe_status) {
 			case KPROBE_HIT_ACTIVE:
@@ -288,7 +296,7 @@ void __kprobes kprobe_handler(struct pt_regs *regs)
 				/* impossible cases */
 				BUG();
 			}
-		} else if (p->ainsn.insn_check_cc(regs->ARM_cpsr)) {
+		} else {
 			/* Probe hit and conditional execution check ok. */
 			set_current_kprobe(p);
 			kcb->kprobe_status = KPROBE_HIT_ACTIVE;
@@ -309,13 +317,6 @@ void __kprobes kprobe_handler(struct pt_regs *regs)
 				}
 				reset_current_kprobe();
 			}
-		} else {
-			/*
-			 * Probe hit but conditional execution check failed,
-			 * so just skip the instruction and continue as if
-			 * nothing had happened.
-			 */
-			singlestep_skip(p, regs);
 		}
 	} else if (cur) {
 		/* We probably hit a jprobe.  Call its break handler. */

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[BUGFIX PATCH V2 0/3] kprobes/arm: Improve kprobes implementation on arm Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-15 01:30 +0100
  [BUGFIX PATCH V2 3/3] kprobes/arm: Fix the return address of multiple kretprobes Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-15 01:40 +0100
  [BUGFIX PATCH V2 2/3] kprobes/arm: Skip single-stepping in recursing path if possible Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-15 01:40 +0100
  Re: [BUGFIX PATCH V2 0/3] kprobes/arm: Improve kprobes  implementation on arm "Jon Medhurst (Tixy)" <tixy@linaro.org> - 2017-02-17 12:10 +0100
    Re: [BUGFIX PATCH V2 0/3] kprobes/arm: Improve kprobes  implementation on arm Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-17 22:50 +0100
      Re: [BUGFIX PATCH V2 0/3] kprobes/arm: Improve kprobes  implementation on arm "Jon Medhurst (Tixy)" <tixy@linaro.org> - 2017-02-22 17:00 +0100
        Re: [BUGFIX PATCH V2 0/3] kprobes/arm: Improve kprobes  implementation on arm Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-23 00:30 +0100

csiph-web