aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kprobes.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kprobes.c')
-rw-r--r--kernel/kprobes.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c4b43430d393..ccec774c716d 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>
@@ -125,30 +126,6 @@ static LIST_HEAD(kprobe_insn_pages);
125static int kprobe_garbage_slots; 126static int kprobe_garbage_slots;
126static int collect_garbage_slots(void); 127static int collect_garbage_slots(void);
127 128
128static int __kprobes check_safety(void)
129{
130 int ret = 0;
131#if defined(CONFIG_PREEMPT) && defined(CONFIG_FREEZER)
132 ret = freeze_processes();
133 if (ret == 0) {
134 struct task_struct *p, *q;
135 do_each_thread(p, q) {
136 if (p != current && p->state == TASK_RUNNING &&
137 p->pid != 0) {
138 printk("Check failed: %s is running\n",p->comm);
139 ret = -1;
140 goto loop_end;
141 }
142 } while_each_thread(p, q);
143 }
144loop_end:
145 thaw_processes();
146#else
147 synchronize_sched();
148#endif
149 return ret;
150}
151
152/** 129/**
153 * __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.
154 * 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.
@@ -236,9 +213,8 @@ static int __kprobes collect_garbage_slots(void)
236{ 213{
237 struct kprobe_insn_page *kip, *next; 214 struct kprobe_insn_page *kip, *next;
238 215
239 /* Ensure no-one is preepmted on the garbages */ 216 /* Ensure no-one is interrupted on the garbages */
240 if (check_safety()) 217 synchronize_sched();
241 return -EAGAIN;
242 218
243 list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) { 219 list_for_each_entry_safe(kip, next, &kprobe_insn_pages, list) {
244 int i; 220 int i;
@@ -729,7 +705,8 @@ int __kprobes register_kprobe(struct kprobe *p)
729 705
730 preempt_disable(); 706 preempt_disable();
731 if (!kernel_text_address((unsigned long) p->addr) || 707 if (!kernel_text_address((unsigned long) p->addr) ||
732 in_kprobes_functions((unsigned long) p->addr)) { 708 in_kprobes_functions((unsigned long) p->addr) ||
709 ftrace_text_reserved(p->addr, p->addr)) {
733 preempt_enable(); 710 preempt_enable();
734 return -EINVAL; 711 return -EINVAL;
735 } 712 }