All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kprobes/x86: opt: free optinsn cache when range check fails
@ 2014-07-28 12:20 Wang Nan
  2014-07-29  1:43 ` Masami Hiramatsu
  2014-08-27 18:36 ` [tip:perf/urgent] kprobes/x86: Free 'optinsn' " tip-bot for Wang Nan
  0 siblings, 2 replies; 10+ messages in thread
From: Wang Nan @ 2014-07-28 12:20 UTC (permalink / raw)
  To: Masami Hiramatsu, Ingo Molnar, Thomas Gleixner, Andi Kleen,
	Pei Feiyue
  Cc: x86, linux-kernel, wangnan0

This patch frees optinsn slot when range check error to prevent memory
leaks. Before this patch, cache entry in kprobe_insn_cache won't be
freed if kprobe optimizing fails due to range check failure.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
---
 arch/x86/kernel/kprobes/opt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index f304773..f1314d0 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -338,8 +338,10 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
 	 * a relative jump.
 	 */
 	rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
-	if (abs(rel) > 0x7fffffff)
+	if (abs(rel) > 0x7fffffff) {
+		__arch_remove_optimized_kprobe(op, 0);
 		return -ERANGE;
+	}
 
 	buf = (u8 *)op->optinsn.insn;
 
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-09-16  8:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-28 12:20 [PATCH] kprobes/x86: opt: free optinsn cache when range check fails Wang Nan
2014-07-29  1:43 ` Masami Hiramatsu
2014-07-29  1:55   ` Wang Nan
2014-07-29 11:36     ` Masami Hiramatsu
2014-08-05  7:49       ` Wang Nan
2014-08-27 12:15   ` Wang Nan
2014-08-27 13:37     ` Masami Hiramatsu
2014-09-15  1:26       ` Wang Nan
2014-09-16  8:59         ` Ingo Molnar
2014-08-27 18:36 ` [tip:perf/urgent] kprobes/x86: Free 'optinsn' " tip-bot for Wang Nan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.