Commit 7aa5b018 authored by Naveen N. Rao's avatar Naveen N. Rao Committed by Michael Ellerman

powerpc/kprobes: Blacklist exception handlers

Introduce __head_end to mark end of the early fixed sections and use it to
blacklist all exception handlers from kprobes.

mpe: We do not need to do anything special for relocatable kernels, where the
exception vectors are split from the main kernel, as the split vectors are
already excluded by the check for kernel_text_address().
Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
[mpe: Move __head_end outside #ifdef 64-bit to unbreak the 32-bit build]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 71f6e58e
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm-generic/sections.h> #include <asm-generic/sections.h>
extern char __head_end[];
#ifdef __powerpc64__ #ifdef __powerpc64__
extern char __start_interrupts[]; extern char __start_interrupts[];
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <asm/code-patching.h> #include <asm/code-patching.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/sstep.h> #include <asm/sstep.h>
#include <asm/sections.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
...@@ -42,6 +43,14 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); ...@@ -42,6 +43,14 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
struct kretprobe_blackpoint kretprobe_blacklist[] = {{NULL, NULL}}; struct kretprobe_blackpoint kretprobe_blacklist[] = {{NULL, NULL}};
bool arch_within_kprobe_blacklist(unsigned long addr)
{
return (addr >= (unsigned long)__kprobes_text_start &&
addr < (unsigned long)__kprobes_text_end) ||
(addr >= (unsigned long)_stext &&
addr < (unsigned long)__head_end);
}
int arch_prepare_kprobe(struct kprobe *p) int arch_prepare_kprobe(struct kprobe *p)
{ {
int ret = 0; int ret = 0;
......
...@@ -77,6 +77,8 @@ SECTIONS ...@@ -77,6 +77,8 @@ SECTIONS
#endif #endif
} :kernel } :kernel
__head_end = .;
/* /*
* If the build dies here, it's likely code in head_64.S is referencing * If the build dies here, it's likely code in head_64.S is referencing
* labels it can't reach, and the linker inserting stubs without the * labels it can't reach, and the linker inserting stubs without the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment