summaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/kprobes
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2014-07-28 20:20:19 +0800
committerIngo Molnar <mingo@kernel.org>2014-08-27 20:24:32 +0200
commit256aae5eac6d328067d1a986a7c5df6f19bdc8b4 (patch)
treed4ae86c28902fab926ec091287514ff60143ff6c /arch/x86/kernel/kprobes
parent68e370289c29e3beac99d59c6d840d470af9dfcf (diff)
downloadlinux-256aae5eac6d328067d1a986a7c5df6f19bdc8b4.tar.gz
linux-256aae5eac6d328067d1a986a7c5df6f19bdc8b4.tar.xz
kprobes/x86: Free 'optinsn' cache when range check fails
This patch frees the 'optinsn' slot when we get a 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> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Pei Feiyue <peifeiyue@huawei.com> Link: http://lkml.kernel.org/r/1406550019-70935-1-git-send-email-wangnan0@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/kprobes')
-rw-r--r--arch/x86/kernel/kprobes/opt.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index f304773285ae..f1314d0bcf0a 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;