mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Wang Nan <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	masami.hiramatsu.pt@hitachi.com, peifeiyue@huawei.com,
	wangnan0@huawei.com, tglx@linutronix.de
Subject: [tip:perf/urgent] kprobes/x86: Free 'optinsn' cache when range check fails
Date: Wed, 27 Aug 2014 11:36:38 -0700	[thread overview]
Message-ID: <tip-256aae5eac6d328067d1a986a7c5df6f19bdc8b4@git.kernel.org> (raw)
In-Reply-To: <1406550019-70935-1-git-send-email-wangnan0@huawei.com>

Commit-ID:  256aae5eac6d328067d1a986a7c5df6f19bdc8b4
Gitweb:     http://git.kernel.org/tip/256aae5eac6d328067d1a986a7c5df6f19bdc8b4
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Mon, 28 Jul 2014 20:20:19 +0800
Committer:  Ingo Molnar <mingo@kernel.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@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>
---
 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;
 

      parent reply	other threads:[~2014-08-27 18:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 12:20 [PATCH] kprobes/x86: opt: free optinsn " 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-bot for Wang Nan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-256aae5eac6d328067d1a986a7c5df6f19bdc8b4@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=peifeiyue@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome