[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-256aae5eac6d328067d1a986a7c5df6f19bdc8b4@git.kernel.org>
Date: Wed, 27 Aug 2014 11:36:38 -0700
From: tip-bot for Wang Nan <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...nel.org,
masami.hiramatsu.pt@...achi.com, peifeiyue@...wei.com,
wangnan0@...wei.com, tglx@...utronix.de
Subject: [tip:perf/urgent] kprobes/x86: Free 'optinsn'
cache when range check fails
Commit-ID: 256aae5eac6d328067d1a986a7c5df6f19bdc8b4
Gitweb: http://git.kernel.org/tip/256aae5eac6d328067d1a986a7c5df6f19bdc8b4
Author: Wang Nan <wangnan0@...wei.com>
AuthorDate: Mon, 28 Jul 2014 20:20:19 +0800
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 27 Aug 2014 20:24:32 +0200
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@...wei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Pei Feiyue <peifeiyue@...wei.com>
Link: http://lkml.kernel.org/r/1406550019-70935-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists