public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip] kprobes: Prohibit probing on BUG() and WARN() address
@ 2019-09-02 11:06 Masami Hiramatsu
  2019-09-02 14:45 ` kbuild test robot
  2019-09-02 15:48 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2019-09-02 11:06 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Steven Rostedt, Masami Hiramatsu, Naveen N . Rao,
	Anil S Keshavamurthy, David S . Miller, linux-kernel

Since BUG() and WARN() may use a trap (e.g. UD2 on x86) to
get the address where the BUG() has occurred, kprobes can not
do single-step out-of-line that instruction. So prohibit
probing on such address.

Without this fix, if someone put a kprobe on WARN(), the
kernel will crash with invalid opcode error instead of
outputing warning message, because kernel can not find
correct bug address.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 kernel/kprobes.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 452151e79535..771054401e35 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1514,7 +1514,8 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	/* Ensure it is not in reserved area nor out of text */
 	if (!kernel_text_address((unsigned long) p->addr) ||
 	    within_kprobe_blacklist((unsigned long) p->addr) ||
-	    jump_label_text_reserved(p->addr, p->addr)) {
+	    jump_label_text_reserved(p->addr, p->addr) ||
+	    find_bug(p->addr)) {
 		ret = -EINVAL;
 		goto out;
 	}


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-03  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-02 11:06 [PATCH -tip] kprobes: Prohibit probing on BUG() and WARN() address Masami Hiramatsu
2019-09-02 14:45 ` kbuild test robot
2019-09-02 15:48 ` kbuild test robot
2019-09-03  9:31   ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox