aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kprobes.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a5e74ddee0e2..c0fa54b276d9 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -319,6 +319,22 @@ struct kprobe __kprobes *get_kprobe(void *addr)
319 return NULL; 319 return NULL;
320} 320}
321 321
322/* Arm a kprobe with text_mutex */
323static void __kprobes arm_kprobe(struct kprobe *kp)
324{
325 mutex_lock(&text_mutex);
326 arch_arm_kprobe(kp);
327 mutex_unlock(&text_mutex);
328}
329
330/* Disarm a kprobe with text_mutex */
331static void __kprobes disarm_kprobe(struct kprobe *kp)
332{
333 mutex_lock(&text_mutex);
334 arch_disarm_kprobe(kp);
335 mutex_unlock(&text_mutex);
336}
337
322/* 338/*
323 * Aggregate handlers for multiple kprobes support - these handlers 339 * Aggregate handlers for multiple kprobes support - these handlers
324 * take care of invoking the individual kprobe handlers on p->list 340 * take care of invoking the individual kprobe handlers on p->list
@@ -538,7 +554,7 @@ static int __kprobes add_new_kprobe(struct kprobe *ap, struct kprobe *p)
538 ap->flags &= ~KPROBE_FLAG_DISABLED; 554 ap->flags &= ~KPROBE_FLAG_DISABLED;
539 if (!kprobes_all_disarmed) 555 if (!kprobes_all_disarmed)
540 /* Arm the breakpoint again. */ 556 /* Arm the breakpoint again. */
541 arch_arm_kprobe(ap); 557 arm_kprobe(ap);
542 } 558 }
543 return 0; 559 return 0;
544} 560}
@@ -789,11 +805,8 @@ static int __kprobes __unregister_kprobe_top(struct kprobe *p)
789 * enabled and not gone - otherwise, the breakpoint would 805 * enabled and not gone - otherwise, the breakpoint would
790 * already have been removed. We save on flushing icache. 806 * already have been removed. We save on flushing icache.
791 */ 807 */
792 if (!kprobes_all_disarmed && !kprobe_disabled(old_p)) { 808 if (!kprobes_all_disarmed && !kprobe_disabled(old_p))
793 mutex_lock(&text_mutex); 809 disarm_kprobe(p);
794 arch_disarm_kprobe(p);
795 mutex_unlock(&text_mutex);
796 }
797 hlist_del_rcu(&old_p->hlist); 810 hlist_del_rcu(&old_p->hlist);
798 } else { 811 } else {
799 if (p->break_handler && !kprobe_gone(p)) 812 if (p->break_handler && !kprobe_gone(p))
@@ -810,7 +823,7 @@ noclean:
810 if (!kprobe_disabled(old_p)) { 823 if (!kprobe_disabled(old_p)) {
811 try_to_disable_aggr_kprobe(old_p); 824 try_to_disable_aggr_kprobe(old_p);
812 if (!kprobes_all_disarmed && kprobe_disabled(old_p)) 825 if (!kprobes_all_disarmed && kprobe_disabled(old_p))
813 arch_disarm_kprobe(old_p); 826 disarm_kprobe(old_p);
814 } 827 }
815 } 828 }
816 return 0; 829 return 0;
@@ -1364,7 +1377,7 @@ int __kprobes disable_kprobe(struct kprobe *kp)
1364 try_to_disable_aggr_kprobe(p); 1377 try_to_disable_aggr_kprobe(p);
1365 1378
1366 if (!kprobes_all_disarmed && kprobe_disabled(p)) 1379 if (!kprobes_all_disarmed && kprobe_disabled(p))
1367 arch_disarm_kprobe(p); 1380 disarm_kprobe(p);
1368out: 1381out:
1369 mutex_unlock(&kprobe_mutex); 1382 mutex_unlock(&kprobe_mutex);
1370 return ret; 1383 return ret;
@@ -1393,7 +1406,7 @@ int __kprobes enable_kprobe(struct kprobe *kp)
1393 } 1406 }
1394 1407
1395 if (!kprobes_all_disarmed && kprobe_disabled(p)) 1408 if (!kprobes_all_disarmed && kprobe_disabled(p))
1396 arch_arm_kprobe(p); 1409 arm_kprobe(p);
1397 1410
1398 p->flags &= ~KPROBE_FLAG_DISABLED; 1411 p->flags &= ~KPROBE_FLAG_DISABLED;
1399 if (p != kp) 1412 if (p != kp)