aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-12-03 15:27:56 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 10:25:17 -0500
commit785d3cd286f0bf67d1bf692559b9ae5de12678f5 (patch)
treed533f0ab4792b1df11a0f862ec7246bb4455869c
parentd30a0c8bf99f0e6a7d8c57bd4524039585ffbced (diff)
ARM kprobes: prevent some functions involved with kprobes from being probed
Signed-off-by: Nicolas Pitre <nico@marvell.com>
-rw-r--r--arch/arm/kernel/entry-armv.S8
-rw-r--r--arch/arm/kernel/kprobes.c2
-rw-r--r--arch/arm/kernel/traps.c9
-rw-r--r--arch/arm/kernel/vmlinux.lds.S1
-rw-r--r--arch/arm/mm/fault.c4
-rw-r--r--include/asm-arm/traps.h9
6 files changed, 20 insertions, 13 deletions
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 12ecc817be3f..3727537f5825 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -58,6 +58,12 @@
58 58
59 .endm 59 .endm
60 60
61#ifdef CONFIG_KPROBES
62 .section .kprobes.text,"ax",%progbits
63#else
64 .text
65#endif
66
61/* 67/*
62 * Invalid mode handlers 68 * Invalid mode handlers
63 */ 69 */
@@ -562,7 +568,7 @@ do_fpe:
562 .data 568 .data
563ENTRY(fp_enter) 569ENTRY(fp_enter)
564 .word no_fp 570 .word no_fp
565 .text 571 .previous
566 572
567no_fp: mov pc, lr 573no_fp: mov pc, lr
568 574
diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c
index a18a8458e99d..450ee2cbfe17 100644
--- a/arch/arm/kernel/kprobes.c
+++ b/arch/arm/kernel/kprobes.c
@@ -55,7 +55,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
55 unsigned long addr = (unsigned long)p->addr; 55 unsigned long addr = (unsigned long)p->addr;
56 int is; 56 int is;
57 57
58 if (addr & 0x3) 58 if (addr & 0x3 || in_exception_text(addr))
59 return -EINVAL; 59 return -EINVAL;
60 60
61 insn = *p->addr; 61 insn = *p->addr;
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index c34db4e868fa..65bb762b2d80 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -46,15 +46,6 @@ __setup("user_debug=", user_debug_setup);
46 46
47static void dump_mem(const char *str, unsigned long bottom, unsigned long top); 47static void dump_mem(const char *str, unsigned long bottom, unsigned long top);
48 48
49static inline int in_exception_text(unsigned long ptr)
50{
51 extern char __exception_text_start[];
52 extern char __exception_text_end[];
53
54 return ptr >= (unsigned long)&__exception_text_start &&
55 ptr < (unsigned long)&__exception_text_end;
56}
57
58void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame) 49void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
59{ 50{
60#ifdef CONFIG_KALLSYMS 51#ifdef CONFIG_KALLSYMS
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 5ff5406666b4..30f732c7fdb5 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -94,6 +94,7 @@ SECTIONS
94 TEXT_TEXT 94 TEXT_TEXT
95 SCHED_TEXT 95 SCHED_TEXT
96 LOCK_TEXT 96 LOCK_TEXT
97 KPROBES_TEXT
97#ifdef CONFIG_MMU 98#ifdef CONFIG_MMU
98 *(.fixup) 99 *(.fixup)
99#endif 100#endif
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 1e7b1ed304d8..28ad7ab1c0cd 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -239,7 +239,7 @@ out:
239 return fault; 239 return fault;
240} 240}
241 241
242static int 242static int __kprobes
243do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) 243do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
244{ 244{
245 struct task_struct *tsk; 245 struct task_struct *tsk;
@@ -338,7 +338,7 @@ no_context:
338 * interrupt or a critical region, and should only copy the information 338 * interrupt or a critical region, and should only copy the information
339 * from the master page table, nothing more. 339 * from the master page table, nothing more.
340 */ 340 */
341static int 341static int __kprobes
342do_translation_fault(unsigned long addr, unsigned int fsr, 342do_translation_fault(unsigned long addr, unsigned int fsr,
343 struct pt_regs *regs) 343 struct pt_regs *regs)
344{ 344{
diff --git a/include/asm-arm/traps.h b/include/asm-arm/traps.h
index d4f34dc83eb0..f1541afcf85c 100644
--- a/include/asm-arm/traps.h
+++ b/include/asm-arm/traps.h
@@ -15,4 +15,13 @@ struct undef_hook {
15void register_undef_hook(struct undef_hook *hook); 15void register_undef_hook(struct undef_hook *hook);
16void unregister_undef_hook(struct undef_hook *hook); 16void unregister_undef_hook(struct undef_hook *hook);
17 17
18static inline int in_exception_text(unsigned long ptr)
19{
20 extern char __exception_text_start[];
21 extern char __exception_text_end[];
22
23 return ptr >= (unsigned long)&__exception_text_start &&
24 ptr < (unsigned long)&__exception_text_end;
25}
26
18#endif 27#endif