aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kprobes.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kprobes.c')
-rw-r--r--kernel/kprobes.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 99865c33a60d..9437e14f36bd 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1146,13 +1146,16 @@ int __kprobes register_kprobe(struct kprobe *p)
1146 return ret; 1146 return ret;
1147 1147
1148 preempt_disable(); 1148 preempt_disable();
1149 jump_label_lock();
1149 if (!kernel_text_address((unsigned long) p->addr) || 1150 if (!kernel_text_address((unsigned long) p->addr) ||
1150 in_kprobes_functions((unsigned long) p->addr) || 1151 in_kprobes_functions((unsigned long) p->addr) ||
1151 ftrace_text_reserved(p->addr, p->addr) || 1152 ftrace_text_reserved(p->addr, p->addr) ||
1152 jump_label_text_reserved(p->addr, p->addr)) { 1153 jump_label_text_reserved(p->addr, p->addr)) {
1153 preempt_enable(); 1154 preempt_enable();
1155 jump_label_unlock();
1154 return -EINVAL; 1156 return -EINVAL;
1155 } 1157 }
1158 jump_label_unlock();
1156 1159
1157 /* User can pass only KPROBE_FLAG_DISABLED to register_kprobe */ 1160 /* User can pass only KPROBE_FLAG_DISABLED to register_kprobe */
1158 p->flags &= KPROBE_FLAG_DISABLED; 1161 p->flags &= KPROBE_FLAG_DISABLED;
@@ -1187,6 +1190,8 @@ int __kprobes register_kprobe(struct kprobe *p)
1187 INIT_LIST_HEAD(&p->list); 1190 INIT_LIST_HEAD(&p->list);
1188 mutex_lock(&kprobe_mutex); 1191 mutex_lock(&kprobe_mutex);
1189 1192
1193 jump_label_lock(); /* needed to call jump_label_text_reserved() */
1194
1190 get_online_cpus(); /* For avoiding text_mutex deadlock. */ 1195 get_online_cpus(); /* For avoiding text_mutex deadlock. */
1191 mutex_lock(&text_mutex); 1196 mutex_lock(&text_mutex);
1192 1197
@@ -1214,6 +1219,7 @@ int __kprobes register_kprobe(struct kprobe *p)
1214out: 1219out:
1215 mutex_unlock(&text_mutex); 1220 mutex_unlock(&text_mutex);
1216 put_online_cpus(); 1221 put_online_cpus();
1222 jump_label_unlock();
1217 mutex_unlock(&kprobe_mutex); 1223 mutex_unlock(&kprobe_mutex);
1218 1224
1219 if (probed_mod) 1225 if (probed_mod)