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


Groups > linux.kernel > #1693756

[PATCH] [BUGFIX] kprobes/x86: Release insn_slot in failure path

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject [PATCH] [BUGFIX] kprobes/x86: Release insn_slot in failure path
Date 2017-07-21 16:50 +0200
Message-ID <u5HpD-62U-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The commit 003002e04ed3 ("kprobes: Fix arch_prepare_kprobe
to handle copy insn failures") returns error if copying
insn failed, but not release allocated insn_slot.

Release insn_slot assigned to ainsn.slot correctly if
copy insn is failed.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 003002e04ed3 ("kprobes: Fix arch_prepare_kprobe to handle copy insn failures")
---
 arch/x86/kernel/kprobes/core.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6b87780..f015371 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)
 
 int arch_prepare_kprobe(struct kprobe *p)
 {
+	int ret;
+
 	if (alternatives_text_reserved(p->addr, p->addr))
 		return -EINVAL;
 
@@ -467,7 +469,13 @@ int arch_prepare_kprobe(struct kprobe *p)
 	if (!p->ainsn.insn)
 		return -ENOMEM;
 
-	return arch_copy_kprobe(p);
+	ret = arch_copy_kprobe(p);
+	if (ret) {
+		free_insn_slot(p->ainsn.insn, 0);
+		p->ainsn.insn = NULL;
+	}
+
+	return ret;
 }
 
 void arch_arm_kprobe(struct kprobe *p)

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


Thread

[PATCH] [BUGFIX] kprobes/x86: Release insn_slot in failure path Masami Hiramatsu <mhiramat@kernel.org> - 2017-07-21 16:50 +0200
  [tip:perf/urgent] kprobes/x86: Release insn_slot in failure path tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2017-07-24 12:30 +0200

csiph-web