]> err.no Git - linux-2.6/commitdiff
ARM kprobes: prevent some functions involved with kprobes from being probed
authorNicolas Pitre <nico@cam.org>
Mon, 3 Dec 2007 20:27:56 +0000 (15:27 -0500)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 26 Jan 2008 15:25:17 +0000 (15:25 +0000)
Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/kernel/entry-armv.S
arch/arm/kernel/kprobes.c
arch/arm/kernel/traps.c
arch/arm/kernel/vmlinux.lds.S
arch/arm/mm/fault.c
include/asm-arm/traps.h

index 12ecc817be3f6b698a3d51b55b7cfaee167e1949..3727537f5825c92925915f3a9240b7bd63e6dd1d 100644 (file)
 
        .endm
 
+#ifdef CONFIG_KPROBES
+       .section        .kprobes.text,"ax",%progbits
+#else
+       .text
+#endif
+
 /*
  * Invalid mode handlers
  */
@@ -562,7 +568,7 @@ do_fpe:
        .data
 ENTRY(fp_enter)
        .word   no_fp
-       .text
+       .previous
 
 no_fp: mov     pc, lr
 
index a18a8458e99d209491de06dcadb55d6223db1ee0..450ee2cbfe17ebfca26b856388c25880955f70c5 100644 (file)
@@ -55,7 +55,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
        unsigned long addr = (unsigned long)p->addr;
        int is;
 
-       if (addr & 0x3)
+       if (addr & 0x3 || in_exception_text(addr))
                return -EINVAL;
 
        insn = *p->addr;
index c34db4e868fa530c50b0e6baa7123c88eab76ec8..65bb762b2d804fed04730ec6986e9bf88bb16bba 100644 (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 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)
 {
 #ifdef CONFIG_KALLSYMS
index 5ff5406666b437c9a8a5b848279d60735b601bc6..30f732c7fdb505b9762b6d12f4fbc6ebf5ebb5ae 100644 (file)
@@ -94,6 +94,7 @@ SECTIONS
                        TEXT_TEXT
                        SCHED_TEXT
                        LOCK_TEXT
+                       KPROBES_TEXT
 #ifdef CONFIG_MMU
                        *(.fixup)
 #endif
index 1e7b1ed304d866d1210c48ee368f7b8d0ecd05d9..28ad7ab1c0cd9cfc506623ec1dbcc91082bc9c14 100644 (file)
@@ -239,7 +239,7 @@ out:
        return fault;
 }
 
-static int
+static int __kprobes
 do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 {
        struct task_struct *tsk;
@@ -338,7 +338,7 @@ no_context:
  * interrupt or a critical region, and should only copy the information
  * from the master page table, nothing more.
  */
-static int
+static int __kprobes
 do_translation_fault(unsigned long addr, unsigned int fsr,
                     struct pt_regs *regs)
 {
index d4f34dc83eb0a20c12c29b7da063f7eb127cd763..f1541afcf85c200c457fb48fc93d5c88d250902d 100644 (file)
@@ -15,4 +15,13 @@ struct undef_hook {
 void register_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