From: tip-bot for Jiri Olsa <jolsa@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de,
mingo@elte.hu, jolsa@redhat.com
Subject: [tip:perf/core] kprobes: Disabling optimized kprobes for entry text section
Date: Tue, 8 Mar 2011 20:16:15 GMT [thread overview]
Message-ID: <tip-2a8247a2600c3e087a568fc68a6ec4eedac27ef1@git.kernel.org> (raw)
In-Reply-To: <1298298313-5980-3-git-send-email-jolsa@redhat.com>
Commit-ID: 2a8247a2600c3e087a568fc68a6ec4eedac27ef1
Gitweb: http://git.kernel.org/tip/2a8247a2600c3e087a568fc68a6ec4eedac27ef1
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 21 Feb 2011 15:25:13 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 8 Mar 2011 17:22:12 +0100
kprobes: Disabling optimized kprobes for entry text section
You can crash the kernel (with root/admin privileges) using kprobe tracer by running:
echo "p system_call_after_swapgs" > ./kprobe_events
echo 1 > ./events/kprobes/enable
The reason is that at the system_call_after_swapgs label, the
kernel stack is not set up. If optimized kprobes are enabled,
the user space stack is being used in this case (see optimized
kprobe template) and this might result in a crash.
There are several places like this over the entry code
(entry_$BIT). As it seems there's no any reasonable/maintainable
way to disable only those places where the stack is not ready, I
switched off the whole entry code from kprobe optimizing.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: acme@redhat.com
Cc: fweisbec@gmail.com
Cc: ananth@in.ibm.com
Cc: davem@davemloft.net
Cc: a.p.zijlstra@chello.nl
Cc: eric.dumazet@gmail.com
Cc: 2nddept-manager@sdl.hitachi.co.jp
LKML-Reference: <1298298313-5980-3-git-send-email-jolsa@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/kprobes.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index d91c477..c969fd9 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -1276,6 +1276,14 @@ static int __kprobes can_optimize(unsigned long paddr)
if (!kallsyms_lookup_size_offset(paddr, &size, &offset))
return 0;
+ /*
+ * Do not optimize in the entry code due to the unstable
+ * stack handling.
+ */
+ if ((paddr >= (unsigned long )__entry_text_start) &&
+ (paddr < (unsigned long )__entry_text_end))
+ return 0;
+
/* Check there is enough space for a relative jump. */
if (size - offset < RELATIVEJUMP_SIZE)
return 0;
prev parent reply other threads:[~2011-03-08 20:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-14 15:12 [RFC,PATCH] kprobes - optimized kprobes might crash before setting kernel stack Jiri Olsa
2011-02-15 9:41 ` Masami Hiramatsu
2011-02-15 12:30 ` Jiri Olsa
2011-02-15 15:55 ` Masami Hiramatsu
2011-02-15 16:54 ` Jiri Olsa
2011-02-15 17:05 ` [PATCH] kprobes - do not allow optimized kprobes in entry code Jiri Olsa
2011-02-16 3:36 ` Masami Hiramatsu
2011-02-17 15:11 ` Ingo Molnar
2011-02-17 15:20 ` Jiri Olsa
2011-02-18 16:26 ` Jiri Olsa
2011-02-19 14:14 ` Masami Hiramatsu
2011-02-20 12:59 ` Ingo Molnar
2011-02-21 11:54 ` Jiri Olsa
2011-02-21 14:25 ` [PATCH 0/2] x86: separating entry text section + kprobes fix Jiri Olsa
2011-02-21 14:25 ` [PATCH 1/2] x86: separating entry text section Jiri Olsa
2011-02-22 3:22 ` Masami Hiramatsu
2011-02-22 8:09 ` Ingo Molnar
2011-02-22 12:52 ` Jiri Olsa
2011-03-07 10:44 ` Jiri Olsa
2011-03-07 15:29 ` Ingo Molnar
2011-03-07 18:10 ` Jiri Olsa
2011-03-08 16:15 ` Ingo Molnar
2011-03-08 20:15 ` [tip:perf/core] x86: Separate out " tip-bot for Jiri Olsa
2011-02-21 14:25 ` [PATCH 2/2] kprobes: disabling optimized kprobes for " Jiri Olsa
2011-02-22 3:22 ` Masami Hiramatsu
2011-03-08 20:16 ` tip-bot for Jiri Olsa [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-2a8247a2600c3e087a568fc68a6ec4eedac27ef1@git.kernel.org \
--to=jolsa@redhat.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@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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