diff options
Diffstat (limited to 'kernel/kprobes.c')
| -rw-r--r-- | kernel/kprobes.c | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index b7df302a020..ccec774c716 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include <linux/debugfs.h> | 44 | #include <linux/debugfs.h> |
| 45 | #include <linux/kdebug.h> | 45 | #include <linux/kdebug.h> |
| 46 | #include <linux/memory.h> | 46 | #include <linux/memory.h> |
| 47 | #include <linux/ftrace.h> | ||
| 47 | 48 | ||
| 48 | #include <asm-generic/sections.h> | 49 | #include <asm-generic/sections.h> |
| 49 | #include <asm/cacheflush.h> | 50 | #include <asm/cacheflush.h> |
| @@ -93,6 +94,7 @@ static struct kprobe_blackpoint kprobe_blacklist[] = { | |||
| 93 | {"native_get_debugreg",}, | 94 | {"native_get_debugreg",}, |
| 94 | {"irq_entries_start",}, | 95 | {"irq_entries_start",}, |
| 95 | {"common_interrupt",}, | 96 | {"common_interrupt",}, |
| 97 | {"mcount",}, /* mcount can be called from everywhere */ | ||
| 96 | {NULL} /* Terminator */ | 98 | {NULL} /* Terminator */ |
| 97 | }; | 99 | }; |
| 98 | 100 | ||
| @@ -124,30 +126,6 @@ static LIST_HEAD(kprobe_insn_pages); | |||
| 124 | static int kprobe_garbage_slots; | 126 | static int kprobe_garbage_slots; |
| 125 | static int collect_garbage_slots(void); | 127 | static int collect_garbage_slots(void); |
| 126 | 128 | ||
| 127 | static int __kprobes check_safety(void) | ||
| 128 | { | ||
| 129 | int ret = 0; | ||
| 130 | #if defined(CONFIG_PREEMPT) && defined(CONFIG_FREEZER) | ||
| 131 | ret = freeze_processes(); | ||
| 132 | if (ret == 0) { | ||
| 133 | struct task_struct *p, *q; | ||
| 134 | do_each_thread(p, q) { | ||
| 135 | if (p != current && p->state == TASK_RUNNING && | ||
| 136 | p->pid != 0) { | ||
| 137 | printk("Check failed: %s is running\n",p->comm); | ||
| 138 | ret = -1; | ||
| 139 | goto loop_end; | ||
| 140 | } | ||
| 141 | } while_each_thread(p, q); | ||
| 142 | } | ||
| 143 | loop_end: | ||
| 144 | thaw_processes(); | ||
| 145 | #else | ||
| 146 | synchronize_sched(); | ||
| 147 | #endif | ||
| 148 | return ret; | ||
| 149 | } | ||
| 150 | |||
| 151 | /** | 129 | /** |
| 152 | * __get_insn_slot() - Find a slot on an executable page for an instruction. | 130 | * __get_insn_slot() - Find a slot on an executable page for an instruction. |
| 153 | * We allocate an executable page if there's no room on existing ones. | 131 | * We allocate an executable page if there's no room on existing ones. |
| @@ -235,9 +213,8 @@ static int __kprobes collect_garbage_slots(void) | |||
| 235 | { | 213 | { |
| 236 | struct kprobe_insn_page *kip, *next; | 214 | struct kprobe_insn_page *kip, *next; |
| 237 | 215 | ||
| 238 | /* Ensure no-one is preepmted on the garbages */ | 216 | /* Ensure no-one is interrupted on the garbages */ |
| 239 | if (check_safety()) | 217 | synchronize_sched(); |
| 240 | return -EAGAIN; | ||
| 241 | 218 | ||
| 242 | list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) { | 219 | list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) { |
| 243 | int i; | 220 | int i; |
| @@ -728,7 +705,8 @@ int __kprobes register_kprobe(struct kprobe *p) | |||
| 728 | 705 | ||
| 729 | preempt_disable(); | 706 | preempt_disable(); |
| 730 | if (!kernel_text_address((unsigned long) p->addr) || | 707 | if (!kernel_text_address((unsigned long) p->addr) || |
| 731 | in_kprobes_functions((unsigned long) p->addr)) { | 708 | in_kprobes_functions((unsigned long) p->addr) || |
| 709 | ftrace_text_reserved(p->addr, p->addr)) { | ||
| 732 | preempt_enable(); | 710 | preempt_enable(); |
| 733 | return -EINVAL; | 711 | return -EINVAL; |
| 734 | } | 712 | } |
