arm64: Treat all entry code as non-kprobe-able
authorPratyush Anand <panand@redhat.com>
Fri, 8 Jul 2016 16:35:50 +0000 (12:35 -0400)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 19 Jul 2016 14:03:21 +0000 (15:03 +0100)
Entry symbols are not kprobe safe. So blacklist them for kprobing.

Signed-off-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
[catalin.marinas@arm.com: Do not include syscall wrappers in .entry.text]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/entry.S
arch/arm64/kernel/probes/kprobes.c
arch/arm64/kernel/vmlinux.lds.S

index 12e8d2bcb3f9da4e643649442685138dea7966d1..492a2655fea47ddc5404b16a4ce6ae78ad57e03f 100644 (file)
@@ -242,6 +242,7 @@ tsk .req    x28             // current thread_info
 /*
  * Exception vectors.
  */
+       .pushsection ".entry.text", "ax"
 
        .align  11
 ENTRY(vectors)
@@ -774,6 +775,8 @@ __ni_sys_trace:
        bl      do_ni_syscall
        b       __sys_trace_return
 
+       .popsection                             // .entry.text
+
 /*
  * Special system call wrappers.
  */
index 44968019ce0d4e3ace09551b80e4cfa0bc4a1af0..0fe2b657816303b6e7f087493725f20f2e759b2b 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/insn.h>
 #include <asm/uaccess.h>
 #include <asm/irq.h>
+#include <asm-generic/sections.h>
 
 #include "decode-insn.h"
 
@@ -519,6 +520,31 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
        return 1;
 }
 
+bool arch_within_kprobe_blacklist(unsigned long addr)
+{
+       extern char __idmap_text_start[], __idmap_text_end[];
+       extern char __hyp_idmap_text_start[], __hyp_idmap_text_end[];
+
+       if ((addr >= (unsigned long)__kprobes_text_start &&
+           addr < (unsigned long)__kprobes_text_end) ||
+           (addr >= (unsigned long)__entry_text_start &&
+           addr < (unsigned long)__entry_text_end) ||
+           (addr >= (unsigned long)__idmap_text_start &&
+           addr < (unsigned long)__idmap_text_end) ||
+           !!search_exception_tables(addr))
+               return true;
+
+       if (!is_kernel_in_hyp_mode()) {
+               if ((addr >= (unsigned long)__hyp_text_start &&
+                   addr < (unsigned long)__hyp_text_end) ||
+                   (addr >= (unsigned long)__hyp_idmap_text_start &&
+                   addr < (unsigned long)__hyp_idmap_text_end))
+                       return true;
+       }
+
+       return false;
+}
+
 int __init arch_init_kprobes(void)
 {
        return 0;
index 075ce322e82bb84eed0a5c0b519e317ca8b0a14c..9f5939469ef60725c06995032a93caa2178d4b23 100644 (file)
@@ -118,6 +118,7 @@ SECTIONS
                        __exception_text_end = .;
                        IRQENTRY_TEXT
                        SOFTIRQENTRY_TEXT
+                       ENTRY_TEXT
                        TEXT_TEXT
                        SCHED_TEXT
                        LOCK_TEXT