Commit 820aede0 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Ingo Molnar

kprobes: Use NOKPROBE_SYMBOL macro instead of __kprobes

Use NOKPROBE_SYMBOL macro to protect functions from
kprobes instead of __kprobes annotation.
Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Reviewed-by: default avatarSteven 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.jpSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 9326638c
...@@ -301,7 +301,7 @@ static inline void reset_kprobe_instance(void) ...@@ -301,7 +301,7 @@ static inline void reset_kprobe_instance(void)
* OR * OR
* - with preemption disabled - from arch/xxx/kernel/kprobes.c * - with preemption disabled - from arch/xxx/kernel/kprobes.c
*/ */
struct kprobe __kprobes *get_kprobe(void *addr) struct kprobe *get_kprobe(void *addr)
{ {
struct hlist_head *head; struct hlist_head *head;
struct kprobe *p; struct kprobe *p;
...@@ -314,8 +314,9 @@ struct kprobe __kprobes *get_kprobe(void *addr) ...@@ -314,8 +314,9 @@ struct kprobe __kprobes *get_kprobe(void *addr)
return NULL; return NULL;
} }
NOKPROBE_SYMBOL(get_kprobe);
static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs); static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs);
/* Return true if the kprobe is an aggregator */ /* Return true if the kprobe is an aggregator */
static inline int kprobe_aggrprobe(struct kprobe *p) static inline int kprobe_aggrprobe(struct kprobe *p)
...@@ -347,7 +348,7 @@ static bool kprobes_allow_optimization; ...@@ -347,7 +348,7 @@ static bool kprobes_allow_optimization;
* Call all pre_handler on the list, but ignores its return value. * Call all pre_handler on the list, but ignores its return value.
* This must be called from arch-dep optimized caller. * This must be called from arch-dep optimized caller.
*/ */
void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs) void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
{ {
struct kprobe *kp; struct kprobe *kp;
...@@ -359,6 +360,7 @@ void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs) ...@@ -359,6 +360,7 @@ void __kprobes opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
reset_kprobe_instance(); reset_kprobe_instance();
} }
} }
NOKPROBE_SYMBOL(opt_pre_handler);
/* Free optimized instructions and optimized_kprobe */ /* Free optimized instructions and optimized_kprobe */
static void free_aggr_kprobe(struct kprobe *p) static void free_aggr_kprobe(struct kprobe *p)
...@@ -995,7 +997,7 @@ static void disarm_kprobe(struct kprobe *kp, bool reopt) ...@@ -995,7 +997,7 @@ static void disarm_kprobe(struct kprobe *kp, bool reopt)
* Aggregate handlers for multiple kprobes support - these handlers * Aggregate handlers for multiple kprobes support - these handlers
* take care of invoking the individual kprobe handlers on p->list * take care of invoking the individual kprobe handlers on p->list
*/ */
static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs) static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
{ {
struct kprobe *kp; struct kprobe *kp;
...@@ -1009,9 +1011,10 @@ static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs) ...@@ -1009,9 +1011,10 @@ static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
} }
return 0; return 0;
} }
NOKPROBE_SYMBOL(aggr_pre_handler);
static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs, static void aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
unsigned long flags) unsigned long flags)
{ {
struct kprobe *kp; struct kprobe *kp;
...@@ -1023,9 +1026,10 @@ static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs, ...@@ -1023,9 +1026,10 @@ static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
} }
} }
} }
NOKPROBE_SYMBOL(aggr_post_handler);
static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, static int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
int trapnr) int trapnr)
{ {
struct kprobe *cur = __this_cpu_read(kprobe_instance); struct kprobe *cur = __this_cpu_read(kprobe_instance);
...@@ -1039,8 +1043,9 @@ static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, ...@@ -1039,8 +1043,9 @@ static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
} }
return 0; return 0;
} }
NOKPROBE_SYMBOL(aggr_fault_handler);
static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs) static int aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
{ {
struct kprobe *cur = __this_cpu_read(kprobe_instance); struct kprobe *cur = __this_cpu_read(kprobe_instance);
int ret = 0; int ret = 0;
...@@ -1052,9 +1057,10 @@ static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs) ...@@ -1052,9 +1057,10 @@ static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
reset_kprobe_instance(); reset_kprobe_instance();
return ret; return ret;
} }
NOKPROBE_SYMBOL(aggr_break_handler);
/* Walks the list and increments nmissed count for multiprobe case */ /* Walks the list and increments nmissed count for multiprobe case */
void __kprobes kprobes_inc_nmissed_count(struct kprobe *p) void kprobes_inc_nmissed_count(struct kprobe *p)
{ {
struct kprobe *kp; struct kprobe *kp;
if (!kprobe_aggrprobe(p)) { if (!kprobe_aggrprobe(p)) {
...@@ -1065,9 +1071,10 @@ void __kprobes kprobes_inc_nmissed_count(struct kprobe *p) ...@@ -1065,9 +1071,10 @@ void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
} }
return; return;
} }
NOKPROBE_SYMBOL(kprobes_inc_nmissed_count);
void __kprobes recycle_rp_inst(struct kretprobe_instance *ri, void recycle_rp_inst(struct kretprobe_instance *ri,
struct hlist_head *head) struct hlist_head *head)
{ {
struct kretprobe *rp = ri->rp; struct kretprobe *rp = ri->rp;
...@@ -1082,8 +1089,9 @@ void __kprobes recycle_rp_inst(struct kretprobe_instance *ri, ...@@ -1082,8 +1089,9 @@ void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
/* Unregistering */ /* Unregistering */
hlist_add_head(&ri->hlist, head); hlist_add_head(&ri->hlist, head);
} }
NOKPROBE_SYMBOL(recycle_rp_inst);
void __kprobes kretprobe_hash_lock(struct task_struct *tsk, void kretprobe_hash_lock(struct task_struct *tsk,
struct hlist_head **head, unsigned long *flags) struct hlist_head **head, unsigned long *flags)
__acquires(hlist_lock) __acquires(hlist_lock)
{ {
...@@ -1094,17 +1102,19 @@ __acquires(hlist_lock) ...@@ -1094,17 +1102,19 @@ __acquires(hlist_lock)
hlist_lock = kretprobe_table_lock_ptr(hash); hlist_lock = kretprobe_table_lock_ptr(hash);
raw_spin_lock_irqsave(hlist_lock, *flags); raw_spin_lock_irqsave(hlist_lock, *flags);
} }
NOKPROBE_SYMBOL(kretprobe_hash_lock);
static void __kprobes kretprobe_table_lock(unsigned long hash, static void kretprobe_table_lock(unsigned long hash,
unsigned long *flags) unsigned long *flags)
__acquires(hlist_lock) __acquires(hlist_lock)
{ {
raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash); raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
raw_spin_lock_irqsave(hlist_lock, *flags); raw_spin_lock_irqsave(hlist_lock, *flags);
} }
NOKPROBE_SYMBOL(kretprobe_table_lock);
void __kprobes kretprobe_hash_unlock(struct task_struct *tsk, void kretprobe_hash_unlock(struct task_struct *tsk,
unsigned long *flags) unsigned long *flags)
__releases(hlist_lock) __releases(hlist_lock)
{ {
unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS); unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
...@@ -1113,14 +1123,16 @@ __releases(hlist_lock) ...@@ -1113,14 +1123,16 @@ __releases(hlist_lock)
hlist_lock = kretprobe_table_lock_ptr(hash); hlist_lock = kretprobe_table_lock_ptr(hash);
raw_spin_unlock_irqrestore(hlist_lock, *flags); raw_spin_unlock_irqrestore(hlist_lock, *flags);
} }
NOKPROBE_SYMBOL(kretprobe_hash_unlock);
static void __kprobes kretprobe_table_unlock(unsigned long hash, static void kretprobe_table_unlock(unsigned long hash,
unsigned long *flags) unsigned long *flags)
__releases(hlist_lock) __releases(hlist_lock)
{ {
raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash); raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
raw_spin_unlock_irqrestore(hlist_lock, *flags); raw_spin_unlock_irqrestore(hlist_lock, *flags);
} }
NOKPROBE_SYMBOL(kretprobe_table_unlock);
/* /*
* This function is called from finish_task_switch when task tk becomes dead, * This function is called from finish_task_switch when task tk becomes dead,
...@@ -1128,7 +1140,7 @@ __releases(hlist_lock) ...@@ -1128,7 +1140,7 @@ __releases(hlist_lock)
* with this task. These left over instances represent probed functions * with this task. These left over instances represent probed functions
* that have been called but will never return. * that have been called but will never return.
*/ */
void __kprobes kprobe_flush_task(struct task_struct *tk) void kprobe_flush_task(struct task_struct *tk)
{ {
struct kretprobe_instance *ri; struct kretprobe_instance *ri;
struct hlist_head *head, empty_rp; struct hlist_head *head, empty_rp;
...@@ -1153,6 +1165,7 @@ void __kprobes kprobe_flush_task(struct task_struct *tk) ...@@ -1153,6 +1165,7 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
kfree(ri); kfree(ri);
} }
} }
NOKPROBE_SYMBOL(kprobe_flush_task);
static inline void free_rp_inst(struct kretprobe *rp) static inline void free_rp_inst(struct kretprobe *rp)
{ {
...@@ -1165,7 +1178,7 @@ static inline void free_rp_inst(struct kretprobe *rp) ...@@ -1165,7 +1178,7 @@ static inline void free_rp_inst(struct kretprobe *rp)
} }
} }
static void __kprobes cleanup_rp_inst(struct kretprobe *rp) static void cleanup_rp_inst(struct kretprobe *rp)
{ {
unsigned long flags, hash; unsigned long flags, hash;
struct kretprobe_instance *ri; struct kretprobe_instance *ri;
...@@ -1184,6 +1197,7 @@ static void __kprobes cleanup_rp_inst(struct kretprobe *rp) ...@@ -1184,6 +1197,7 @@ static void __kprobes cleanup_rp_inst(struct kretprobe *rp)
} }
free_rp_inst(rp); free_rp_inst(rp);
} }
NOKPROBE_SYMBOL(cleanup_rp_inst);
/* /*
* Add the new probe to ap->list. Fail if this is the * Add the new probe to ap->list. Fail if this is the
...@@ -1758,8 +1772,7 @@ EXPORT_SYMBOL_GPL(unregister_jprobes); ...@@ -1758,8 +1772,7 @@ EXPORT_SYMBOL_GPL(unregister_jprobes);
* This kprobe pre_handler is registered with every kretprobe. When probe * This kprobe pre_handler is registered with every kretprobe. When probe
* hits it will set up the return probe. * hits it will set up the return probe.
*/ */
static int __kprobes pre_handler_kretprobe(struct kprobe *p, static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
struct pt_regs *regs)
{ {
struct kretprobe *rp = container_of(p, struct kretprobe, kp); struct kretprobe *rp = container_of(p, struct kretprobe, kp);
unsigned long hash, flags = 0; unsigned long hash, flags = 0;
...@@ -1797,6 +1810,7 @@ static int __kprobes pre_handler_kretprobe(struct kprobe *p, ...@@ -1797,6 +1810,7 @@ static int __kprobes pre_handler_kretprobe(struct kprobe *p,
} }
return 0; return 0;
} }
NOKPROBE_SYMBOL(pre_handler_kretprobe);
int register_kretprobe(struct kretprobe *rp) int register_kretprobe(struct kretprobe *rp)
{ {
...@@ -1920,11 +1934,11 @@ void unregister_kretprobes(struct kretprobe **rps, int num) ...@@ -1920,11 +1934,11 @@ void unregister_kretprobes(struct kretprobe **rps, int num)
} }
EXPORT_SYMBOL_GPL(unregister_kretprobes); EXPORT_SYMBOL_GPL(unregister_kretprobes);
static int __kprobes pre_handler_kretprobe(struct kprobe *p, static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
struct pt_regs *regs)
{ {
return 0; return 0;
} }
NOKPROBE_SYMBOL(pre_handler_kretprobe);
#endif /* CONFIG_KRETPROBES */ #endif /* CONFIG_KRETPROBES */
...@@ -2002,12 +2016,13 @@ int enable_kprobe(struct kprobe *kp) ...@@ -2002,12 +2016,13 @@ int enable_kprobe(struct kprobe *kp)
} }
EXPORT_SYMBOL_GPL(enable_kprobe); EXPORT_SYMBOL_GPL(enable_kprobe);
void __kprobes dump_kprobe(struct kprobe *kp) void dump_kprobe(struct kprobe *kp)
{ {
printk(KERN_WARNING "Dumping kprobe:\n"); printk(KERN_WARNING "Dumping kprobe:\n");
printk(KERN_WARNING "Name: %s\nAddress: %p\nOffset: %x\n", printk(KERN_WARNING "Name: %s\nAddress: %p\nOffset: %x\n",
kp->symbol_name, kp->addr, kp->offset); kp->symbol_name, kp->addr, kp->offset);
} }
NOKPROBE_SYMBOL(dump_kprobe);
/* /*
* Lookup and populate the kprobe_blacklist. * Lookup and populate the kprobe_blacklist.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment