Skip to content

Commit 820aede

Browse files
mhiramathitachiingomolnar
authored andcommitted
kprobes: Use NOKPROBE_SYMBOL macro instead of __kprobes
Use NOKPROBE_SYMBOL macro to protect functions from kprobes instead of __kprobes annotation. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: David S. Miller <davem@davemloft.net> Link: http://lkml.kernel.org/r/20140417081821.26341.40362.stgit@ltc230.yrl.intra.hitachi.co.jp Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 9326638 commit 820aede

1 file changed

Lines changed: 41 additions & 26 deletions

File tree

‎kernel/kprobes.c‎

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static inline void reset_kprobe_instance(void)
301301
* OR
302302
* - with preemption disabled - from arch/xxx/kernel/kprobes.c
303303
*/
304-
struct kprobe __kprobes *get_kprobe(void *addr)
304+
struct kprobe *get_kprobe(void *addr)
305305
{
306306
struct hlist_head *head;
307307
struct kprobe *p;
@@ -314,8 +314,9 @@ struct kprobe __kprobes *get_kprobe(void *addr)
314314

315315
return NULL;
316316
}
317+
NOKPROBE_SYMBOL(get_kprobe);
317318

318-
static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs);
319+
static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs);
319320

320321
/* Return true if the kprobe is an aggregator */
321322
static inline int kprobe_aggrprobe(struct kprobe *p)
@@ -347,7 +348,7 @@ static bool kprobes_allow_optimization;
347348
* Call all pre_handler on the list, but ignores its return value.
348349
* This must be called from arch-dep optimized caller.
349350
*/
350-
void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
351+
void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
351352
{
352353
struct kprobe *kp;
353354

@@ -359,6 +360,7 @@ void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
359360
reset_kprobe_instance();
360361
}
361362
}
363+
NOKPROBE_SYMBOL(opt_pre_handler);
362364

363365
/* Free optimized instructions and optimized_kprobe */
364366
static void free_aggr_kprobe(struct kprobe *p)
@@ -995,7 +997,7 @@ static void disarm_kprobe(struct kprobe *kp, bool reopt)
995997
* Aggregate handlers for multiple kprobes support - these handlers
996998
* take care of invoking the individual kprobe handlers on p->list
997999
*/
998-
static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
1000+
static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
9991001
{
10001002
struct kprobe *kp;
10011003

@@ -1009,9 +1011,10 @@ static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
10091011
}
10101012
return 0;
10111013
}
1014+
NOKPROBE_SYMBOL(aggr_pre_handler);
10121015

1013-
static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
1014-
unsigned long flags)
1016+
static void aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
1017+
unsigned long flags)
10151018
{
10161019
struct kprobe *kp;
10171020

@@ -1023,9 +1026,10 @@ static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
10231026
}
10241027
}
10251028
}
1029+
NOKPROBE_SYMBOL(aggr_post_handler);
10261030

1027-
static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
1028-
int trapnr)
1031+
static int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
1032+
int trapnr)
10291033
{
10301034
struct kprobe *cur = __this_cpu_read(kprobe_instance);
10311035

@@ -1039,8 +1043,9 @@ static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
10391043
}
10401044
return 0;
10411045
}
1046+
NOKPROBE_SYMBOL(aggr_fault_handler);
10421047

1043-
static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
1048+
static int aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
10441049
{
10451050
struct kprobe *cur = __this_cpu_read(kprobe_instance);
10461051
int ret = 0;
@@ -1052,9 +1057,10 @@ static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
10521057
reset_kprobe_instance();
10531058
return ret;
10541059
}
1060+
NOKPROBE_SYMBOL(aggr_break_handler);
10551061

10561062
/* Walks the list and increments nmissed count for multiprobe case */
1057-
void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
1063+
void kprobes_inc_nmissed_count(struct kprobe *p)
10581064
{
10591065
struct kprobe *kp;
10601066
if (!kprobe_aggrprobe(p)) {
@@ -1065,9 +1071,10 @@ void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
10651071
}
10661072
return;
10671073
}
1074+
NOKPROBE_SYMBOL(kprobes_inc_nmissed_count);
10681075

1069-
void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
1070-
struct hlist_head *head)
1076+
void recycle_rp_inst(struct kretprobe_instance *ri,
1077+
struct hlist_head *head)
10711078
{
10721079
struct kretprobe *rp = ri->rp;
10731080

@@ -1082,8 +1089,9 @@ void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
10821089
/* Unregistering */
10831090
hlist_add_head(&ri->hlist, head);
10841091
}
1092+
NOKPROBE_SYMBOL(recycle_rp_inst);
10851093

1086-
void __kprobes kretprobe_hash_lock(struct task_struct *tsk,
1094+
void kretprobe_hash_lock(struct task_struct *tsk,
10871095
struct hlist_head **head, unsigned long *flags)
10881096
__acquires(hlist_lock)
10891097
{
@@ -1094,17 +1102,19 @@ __acquires(hlist_lock)
10941102
hlist_lock = kretprobe_table_lock_ptr(hash);
10951103
raw_spin_lock_irqsave(hlist_lock, *flags);
10961104
}
1105+
NOKPROBE_SYMBOL(kretprobe_hash_lock);
10971106

1098-
static void __kprobes kretprobe_table_lock(unsigned long hash,
1099-
unsigned long *flags)
1107+
static void kretprobe_table_lock(unsigned long hash,
1108+
unsigned long *flags)
11001109
__acquires(hlist_lock)
11011110
{
11021111
raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
11031112
raw_spin_lock_irqsave(hlist_lock, *flags);
11041113
}
1114+
NOKPROBE_SYMBOL(kretprobe_table_lock);
11051115

1106-
void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
1107-
unsigned long *flags)
1116+
void kretprobe_hash_unlock(struct task_struct *tsk,
1117+
unsigned long *flags)
11081118
__releases(hlist_lock)
11091119
{
11101120
unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
@@ -1113,22 +1123,24 @@ __releases(hlist_lock)
11131123
hlist_lock = kretprobe_table_lock_ptr(hash);
11141124
raw_spin_unlock_irqrestore(hlist_lock, *flags);
11151125
}
1126+
NOKPROBE_SYMBOL(kretprobe_hash_unlock);
11161127

1117-
static void __kprobes kretprobe_table_unlock(unsigned long hash,
1118-
unsigned long *flags)
1128+
static void kretprobe_table_unlock(unsigned long hash,
1129+
unsigned long *flags)
11191130
__releases(hlist_lock)
11201131
{
11211132
raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
11221133
raw_spin_unlock_irqrestore(hlist_lock, *flags);
11231134
}
1135+
NOKPROBE_SYMBOL(kretprobe_table_unlock);
11241136

11251137
/*
11261138
* This function is called from finish_task_switch when task tk becomes dead,
11271139
* so that we can recycle any function-return probe instances associated
11281140
* with this task. These left over instances represent probed functions
11291141
* that have been called but will never return.
11301142
*/
1131-
void __kprobes kprobe_flush_task(struct task_struct *tk)
1143+
void kprobe_flush_task(struct task_struct *tk)
11321144
{
11331145
struct kretprobe_instance *ri;
11341146
struct hlist_head *head, empty_rp;
@@ -1153,6 +1165,7 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
11531165
kfree(ri);
11541166
}
11551167
}
1168+
NOKPROBE_SYMBOL(kprobe_flush_task);
11561169

11571170
static inline void free_rp_inst(struct kretprobe *rp)
11581171
{
@@ -1165,7 +1178,7 @@ static inline void free_rp_inst(struct kretprobe *rp)
11651178
}
11661179
}
11671180

1168-
static void __kprobes cleanup_rp_inst(struct kretprobe *rp)
1181+
static void cleanup_rp_inst(struct kretprobe *rp)
11691182
{
11701183
unsigned long flags, hash;
11711184
struct kretprobe_instance *ri;
@@ -1184,6 +1197,7 @@ static void __kprobes cleanup_rp_inst(struct kretprobe *rp)
11841197
}
11851198
free_rp_inst(rp);
11861199
}
1200+
NOKPROBE_SYMBOL(cleanup_rp_inst);
11871201

11881202
/*
11891203
* Add the new probe to ap->list. Fail if this is the
@@ -1758,8 +1772,7 @@ EXPORT_SYMBOL_GPL(unregister_jprobes);
17581772
* This kprobe pre_handler is registered with every kretprobe. When probe
17591773
* hits it will set up the return probe.
17601774
*/
1761-
static int __kprobes pre_handler_kretprobe(struct kprobe *p,
1762-
struct pt_regs *regs)
1775+
static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
17631776
{
17641777
struct kretprobe *rp = container_of(p, struct kretprobe, kp);
17651778
unsigned long hash, flags = 0;
@@ -1797,6 +1810,7 @@ static int __kprobes pre_handler_kretprobe(struct kprobe *p,
17971810
}
17981811
return 0;
17991812
}
1813+
NOKPROBE_SYMBOL(pre_handler_kretprobe);
18001814

18011815
int register_kretprobe(struct kretprobe *rp)
18021816
{
@@ -1920,11 +1934,11 @@ void unregister_kretprobes(struct kretprobe **rps, int num)
19201934
}
19211935
EXPORT_SYMBOL_GPL(unregister_kretprobes);
19221936

1923-
static int __kprobes pre_handler_kretprobe(struct kprobe *p,
1924-
struct pt_regs *regs)
1937+
static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
19251938
{
19261939
return 0;
19271940
}
1941+
NOKPROBE_SYMBOL(pre_handler_kretprobe);
19281942

19291943
#endif /* CONFIG_KRETPROBES */
19301944

@@ -2002,12 +2016,13 @@ int enable_kprobe(struct kprobe *kp)
20022016
}
20032017
EXPORT_SYMBOL_GPL(enable_kprobe);
20042018

2005-
void __kprobes dump_kprobe(struct kprobe *kp)
2019+
void dump_kprobe(struct kprobe *kp)
20062020
{
20072021
printk(KERN_WARNING "Dumping kprobe:\n");
20082022
printk(KERN_WARNING "Name: %s\nAddress: %p\nOffset: %x\n",
20092023
kp->symbol_name, kp->addr, kp->offset);
20102024
}
2025+
NOKPROBE_SYMBOL(dump_kprobe);
20112026

20122027
/*
20132028
* Lookup and populate the kprobe_blacklist.

0 commit comments

Comments
 (0)