diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2017-07-21 10:45:52 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-07-24 05:14:59 -0400 |
commit | 38115f2f8cec8087d558c062e779c443a01f87d6 (patch) | |
tree | df0a9098d79c49399c08b2c2441a55fd5327a8c7 | |
parent | ba883b4abc9cd837441b01eb9cf8d9196181294d (diff) |
kprobes/x86: Release insn_slot in failure path
The following commit:
003002e04ed3 ("kprobes: Fix arch_prepare_kprobe to handle copy insn failures")
returns an error if the copying of the instruction, but does not release
the allocated insn_slot.
Clean up correctly.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David S . Miller <davem@davemloft.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 003002e04ed3 ("kprobes: Fix arch_prepare_kprobe to handle copy insn failures")
Link: http://lkml.kernel.org/r/150064834183.6172.11694375818447664416.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/kprobes/core.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 6b877807598b..f0153714ddac 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
@@ -457,6 +457,8 @@ static int arch_copy_kprobe(struct kprobe *p) | |||
457 | 457 | ||
458 | int arch_prepare_kprobe(struct kprobe *p) | 458 | int arch_prepare_kprobe(struct kprobe *p) |
459 | { | 459 | { |
460 | int ret; | ||
461 | |||
460 | if (alternatives_text_reserved(p->addr, p->addr)) | 462 | if (alternatives_text_reserved(p->addr, p->addr)) |
461 | return -EINVAL; | 463 | return -EINVAL; |
462 | 464 | ||
@@ -467,7 +469,13 @@ int arch_prepare_kprobe(struct kprobe *p) | |||
467 | if (!p->ainsn.insn) | 469 | if (!p->ainsn.insn) |
468 | return -ENOMEM; | 470 | return -ENOMEM; |
469 | 471 | ||
470 | return arch_copy_kprobe(p); | 472 | ret = arch_copy_kprobe(p); |
473 | if (ret) { | ||
474 | free_insn_slot(p->ainsn.insn, 0); | ||
475 | p->ainsn.insn = NULL; | ||
476 | } | ||
477 | |||
478 | return ret; | ||
471 | } | 479 | } |
472 | 480 | ||
473 | void arch_arm_kprobe(struct kprobe *p) | 481 | void arch_arm_kprobe(struct kprobe *p) |