aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/kprobes.c67
1 files changed, 41 insertions, 26 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 4db2cc616f50..a21b4e67fd97 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -301,7 +301,7 @@ static inline void reset_kprobe_instance(void)
301 * OR 301 * OR
302 * - with preemption disabled - from arch/xxx/kernel/kprobes.c 302 * - with preemption disabled - from arch/xxx/kernel/kprobes.c
303 */ 303 */
304struct kprobe __kprobes *get_kprobe(void *addr) 304struct kprobe *get_kprobe(void *addr)
305{ 305{
306 struct hlist_head *head; 306 struct hlist_head *head;
307 struct kprobe *p; 307 struct kprobe *p;
@@ -314,8 +314,9 @@ struct kprobe __kprobes *get_kprobe(void *addr)
314 314
315 return NULL; 315 return NULL;
316} 316}
317NOKPROBE_SYMBOL(get_kprobe);
317 318
318static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs); 319static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs);
319 320
320/* Return true if the kprobe is an aggregator */ 321/* Return true if the kprobe is an aggregator */
321static inline int kprobe_aggrprobe(struct kprobe *p) 322static inline int kprobe_aggrprobe(struct kprobe *p)
@@ -347,7 +348,7 @@ static bool kprobes_allow_optimization;
347 * Call all pre_handler on the list, but ignores its return value. 348 * Call all pre_handler on the list, but ignores its return value.
348 * This must be called from arch-dep optimized caller. 349 * This must be called from arch-dep optimized caller.
349 */ 350 */
350void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs) 351void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
351{ 352{
352 struct kprobe *kp; 353 struct kprobe *kp;
353 354
@@ -359,6 +360,7 @@ void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
359 reset_kprobe_instance(); 360 reset_kprobe_instance();
360 } 361 }
361} 362}
363NOKPROBE_SYMBOL(opt_pre_handler);
362 364
363/* Free optimized instructions and optimized_kprobe */ 365/* Free optimized instructions and optimized_kprobe */
364static void free_aggr_kprobe(struct kprobe *p) 366static void free_aggr_kprobe(struct kprobe *p)
@@ -995,7 +997,7 @@ static void disarm_kprobe(struct kprobe *kp, bool reopt)
995 * Aggregate handlers for multiple kprobes support - these handlers 997 * Aggregate handlers for multiple kprobes support - these handlers
996 * take care of invoking the individual kprobe handlers on p->list 998 * take care of invoking the individual kprobe handlers on p->list
997 */ 999 */
998static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs) 1000static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
999{ 1001{
1000 struct kprobe *kp; 1002 struct kprobe *kp;
1001 1003
@@ -1009,9 +1011,10 @@ static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
1009 } 1011 }
1010 return 0; 1012 return 0;
1011} 1013}
1014NOKPROBE_SYMBOL(aggr_pre_handler);
1012 1015
1013static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs, 1016static void aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
1014 unsigned long flags) 1017 unsigned long flags)
1015{ 1018{
1016 struct kprobe *kp; 1019 struct kprobe *kp;
1017 1020
@@ -1023,9 +1026,10 @@ static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
1023 } 1026 }
1024 } 1027 }
1025} 1028}
1029NOKPROBE_SYMBOL(aggr_post_handler);
1026 1030
1027static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, 1031static int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
1028 int trapnr) 1032 int trapnr)
1029{ 1033{
1030 struct kprobe *cur = __this_cpu_read(kprobe_instance); 1034 struct kprobe *cur = __this_cpu_read(kprobe_instance);
1031 1035
@@ -1039,8 +1043,9 @@ static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
1039 } 1043 }
1040 return 0; 1044 return 0;
1041} 1045}
1046NOKPROBE_SYMBOL(aggr_fault_handler);
1042 1047
1043static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs) 1048static int aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
1044{ 1049{
1045 struct kprobe *cur = __this_cpu_read(kprobe_instance); 1050 struct kprobe *cur = __this_cpu_read(kprobe_instance);
1046 int ret = 0; 1051 int ret = 0;
@@ -1052,9 +1057,10 @@ static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
1052 reset_kprobe_instance(); 1057 reset_kprobe_instance();
1053 return ret; 1058 return ret;
1054} 1059}
1060NOKPROBE_SYMBOL(aggr_break_handler);
1055 1061
1056/* Walks the list and increments nmissed count for multiprobe case */ 1062/* Walks the list and increments nmissed count for multiprobe case */
1057void __kprobes kprobes_inc_nmissed_count(struct kprobe *p) 1063void kprobes_inc_nmissed_count(struct kprobe *p)
1058{ 1064{
1059 struct kprobe *kp; 1065 struct kprobe *kp;
1060 if (!kprobe_aggrprobe(p)) { 1066 if (!kprobe_aggrprobe(p)) {
@@ -1065,9 +1071,10 @@ void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
1065 } 1071 }
1066 return; 1072 return;
1067} 1073}
1074NOKPROBE_SYMBOL(kprobes_inc_nmissed_count);
1068 1075
1069void __kprobes recycle_rp_inst(struct kretprobe_instance *ri, 1076void recycle_rp_inst(struct kretprobe_instance *ri,
1070 struct hlist_head *head) 1077 struct hlist_head *head)
1071{ 1078{
1072 struct kretprobe *rp = ri->rp; 1079 struct kretprobe *rp = ri->rp;
1073 1080
@@ -1082,8 +1089,9 @@ void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
1082 /* Unregistering */ 1089 /* Unregistering */
1083 hlist_add_head(&ri->hlist, head); 1090 hlist_add_head(&ri->hlist, head);
1084} 1091}
1092NOKPROBE_SYMBOL(recycle_rp_inst);
1085 1093
1086void __kprobes kretprobe_hash_lock(struct task_struct *tsk, 1094void kretprobe_hash_lock(struct task_struct *tsk,
1087 struct hlist_head **head, unsigned long *flags) 1095 struct hlist_head **head, unsigned long *flags)
1088__acquires(hlist_lock) 1096__acquires(hlist_lock)
1089{ 1097{
@@ -1094,17 +1102,19 @@ __acquires(hlist_lock)
1094 hlist_lock = kretprobe_table_lock_ptr(hash); 1102 hlist_lock = kretprobe_table_lock_ptr(hash);
1095 raw_spin_lock_irqsave(hlist_lock, *flags); 1103 raw_spin_lock_irqsave(hlist_lock, *flags);
1096} 1104}
1105NOKPROBE_SYMBOL(kretprobe_hash_lock);
1097 1106
1098static void __kprobes kretprobe_table_lock(unsigned long hash, 1107static void kretprobe_table_lock(unsigned long hash,
1099 unsigned long *flags) 1108 unsigned long *flags)
1100__acquires(hlist_lock) 1109__acquires(hlist_lock)
1101{ 1110{
1102 raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash); 1111 raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
1103 raw_spin_lock_irqsave(hlist_lock, *flags); 1112 raw_spin_lock_irqsave(hlist_lock, *flags);
1104} 1113}
1114NOKPROBE_SYMBOL(kretprobe_table_lock);
1105 1115
1106void __kprobes kretprobe_hash_unlock(struct task_struct *tsk, 1116void kretprobe_hash_unlock(struct task_struct *tsk,
1107 unsigned long *flags) 1117 unsigned long *flags)
1108__releases(hlist_lock) 1118__releases(hlist_lock)
1109{ 1119{
1110 unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS); 1120 unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
@@ -1113,14 +1123,16 @@ __releases(hlist_lock)
1113 hlist_lock = kretprobe_table_lock_ptr(hash); 1123 hlist_lock = kretprobe_table_lock_ptr(hash);
1114 raw_spin_unlock_irqrestore(hlist_lock, *flags); 1124 raw_spin_unlock_irqrestore(hlist_lock, *flags);
1115} 1125}
1126NOKPROBE_SYMBOL(kretprobe_hash_unlock);
1116 1127
1117static void __kprobes kretprobe_table_unlock(unsigned long hash, 1128static void kretprobe_table_unlock(unsigned long hash,
1118 unsigned long *flags) 1129 unsigned long *flags)
1119__releases(hlist_lock) 1130__releases(hlist_lock)
1120{ 1131{
1121 raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash); 1132 raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
1122 raw_spin_unlock_irqrestore(hlist_lock, *flags); 1133 raw_spin_unlock_irqrestore(hlist_lock, *flags);
1123} 1134}
1135NOKPROBE_SYMBOL(kretprobe_table_unlock);
1124 1136
1125/* 1137/*
1126 * This function is called from finish_task_switch when task tk becomes dead, 1138 * This function is called from finish_task_switch when task tk becomes dead,
@@ -1128,7 +1140,7 @@ __releases(hlist_lock)
1128 * with this task. These left over instances represent probed functions 1140 * with this task. These left over instances represent probed functions
1129 * that have been called but will never return. 1141 * that have been called but will never return.
1130 */ 1142 */
1131void __kprobes kprobe_flush_task(struct task_struct *tk) 1143void kprobe_flush_task(struct task_struct *tk)
1132{ 1144