From: Wang Nan Date: Mon, 28 Jul 2014 12:20:19 +0000 (+0800) Subject: kprobes/x86: Free 'optinsn' cache when range check fails X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=256aae5eac6d328067d1a986a7c5df6f19bdc8b4;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Acked-by: Masami Hiramatsu Cc: Pei Feiyue Link: http://lkml.kernel.org/r/1406550019-70935-1-git-send-email-wangnan0@huawei.com Signed-off-by: Ingo Molnar --- 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;