[RFC PATCH 2/4] powerpc: kprobe: add arch specific blacklist
From: Naveen N. Rao <hidden>
Date: 2016-11-17 15:09:30
Subsystem:
linux for powerpc (32-bit and 64-bit), the rest · Maintainers:
Madhavan Srinivasan, Linus Torvalds
Add symbol to mark end of entry_*.S and use the same to blacklist all addresses from kernel start (_stext) to entry code from kprobes. Much of this code is early exception handling where we can't really take a trap. Reported-by: Anton Blanchard <redacted> Signed-off-by: Naveen N. Rao <redacted> --- arch/powerpc/kernel/entry_32.S | 2 ++ arch/powerpc/kernel/entry_64.S | 2 ++ arch/powerpc/kernel/kprobes.c | 10 ++++++++++ 3 files changed, 14 insertions(+)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 3841d74..de1ed6e 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S@@ -1410,3 +1410,5 @@ _GLOBAL(return_to_handler) #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ #endif /* CONFIG_FUNCTION_TRACER */ + +_GLOBAL_SYM(__entry_text_end)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 6432d4b..f5f99920 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S@@ -1551,3 +1551,5 @@ _GLOBAL(return_to_handler) blr #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ #endif /* CONFIG_FUNCTION_TRACER */ + +_GLOBAL_SYM(__entry_text_end)
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 9479d8e..b5173d6 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c@@ -36,12 +36,22 @@ #include <asm/cacheflush.h> #include <asm/sstep.h> #include <asm/uaccess.h> +#include <asm/sections.h> DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); struct kretprobe_blackpoint kretprobe_blacklist[] = {{NULL, NULL}}; +bool arch_within_kprobe_blacklist(unsigned long addr) +{ + /* The __kprobes marked functions and entry code must not be probed */ + return (addr >= (unsigned long)__kprobes_text_start && + addr < (unsigned long)__kprobes_text_end) || + (addr >= (unsigned long)_stext && + addr < (unsigned long)__entry_text_end); +} + int __kprobes arch_prepare_kprobe(struct kprobe *p) { int ret = 0;
--
2.10.2