ARM kprobes: prevent some functions involved with kprobes from being probed

Signed-off-by: Nicolas Pitre <nico@marvell.com>
This commit is contained in:
Nicolas Pitre 2007-12-03 15:27:56 -05:00 committed by Russell King
parent d30a0c8bf9
commit 785d3cd286
6 changed files with 20 additions and 13 deletions

View file

@ -58,6 +58,12 @@
.endm .endm
#ifdef CONFIG_KPROBES
.section .kprobes.text,"ax",%progbits
#else
.text
#endif
/* /*
* Invalid mode handlers * Invalid mode handlers
*/ */
@ -562,7 +568,7 @@ do_fpe:
.data .data
ENTRY(fp_enter) ENTRY(fp_enter)
.word no_fp .word no_fp
.text .previous
no_fp: mov pc, lr no_fp: mov pc, lr

View file

@ -55,7 +55,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
unsigned long addr = (unsigned long)p->addr; unsigned long addr = (unsigned long)p->addr;
int is; int is;
if (addr & 0x3) if (addr & 0x3 || in_exception_text(addr))
return -EINVAL; return -EINVAL;
insn = *p->addr; insn = *p->addr;

View file

@ -46,15 +46,6 @@ __setup("user_debug=", user_debug_setup);
static void dump_mem(const char *str, unsigned long bottom, unsigned long top); static void dump_mem(const char *str, unsigned long bottom, unsigned long top);
static inline int in_exception_text(unsigned long ptr)
{
extern char __exception_text_start[];
extern char __exception_text_end[];
return ptr >= (unsigned long)&__exception_text_start &&
ptr < (unsigned long)&__exception_text_end;
}
void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame) void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
{ {
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS

View file

@ -94,6 +94,7 @@ SECTIONS
TEXT_TEXT TEXT_TEXT
SCHED_TEXT SCHED_TEXT
LOCK_TEXT LOCK_TEXT
KPROBES_TEXT
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
*(.fixup) *(.fixup)
#endif #endif

View file

@ -239,7 +239,7 @@ out:
return fault; return fault;
} }
static int static int __kprobes
do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{ {
struct task_struct *tsk; struct task_struct *tsk;
@ -338,7 +338,7 @@ no_context:
* interrupt or a critical region, and should only copy the information * interrupt or a critical region, and should only copy the information
* from the master page table, nothing more. * from the master page table, nothing more.
*/ */
static int static int __kprobes
do_translation_fault(unsigned long addr, unsigned int fsr, do_translation_fault(unsigned long addr, unsigned int fsr,
struct pt_regs *regs) struct pt_regs *regs)
{ {

View file

@ -15,4 +15,13 @@ struct undef_hook {
void register_undef_hook(struct undef_hook *hook); void register_undef_hook(struct undef_hook *hook);
void unregister_undef_hook(struct undef_hook *hook); void unregister_undef_hook(struct undef_hook *hook);
static inline int in_exception_text(unsigned long ptr)
{
extern char __exception_text_start[];
extern char __exception_text_end[];
return ptr >= (unsigned long)&__exception_text_start &&
ptr < (unsigned long)&__exception_text_end;
}
#endif #endif