aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kprobes.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kprobes.h')
-rw-r--r--include/linux/kprobes.h74
1 files changed, 66 insertions, 8 deletions
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 32851eef48f0..bcd9c07848be 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -94,12 +94,16 @@ struct kprobe {
94 /* Called after addr is executed, unless... */ 94 /* Called after addr is executed, unless... */
95 kprobe_post_handler_t post_handler; 95 kprobe_post_handler_t post_handler;
96 96
97 /* ... called if executing addr causes a fault (eg. page fault). 97 /*
98 * Return 1 if it handled fault, otherwise kernel will see it. */ 98 * ... called if executing addr causes a fault (eg. page fault).
99 * Return 1 if it handled fault, otherwise kernel will see it.
100 */
99 kprobe_fault_handler_t fault_handler; 101 kprobe_fault_handler_t fault_handler;
100 102
101 /* ... called if breakpoint trap occurs in probe handler. 103 /*
102 * Return 1 if it handled break, otherwise kernel will see it. */ 104 * ... called if breakpoint trap occurs in probe handler.
105 * Return 1 if it handled break, otherwise kernel will see it.
106 */
103 kprobe_break_handler_t break_handler; 107 kprobe_break_handler_t break_handler;
104 108
105 /* Saved opcode (which has been replaced with breakpoint) */ 109 /* Saved opcode (which has been replaced with breakpoint) */
@@ -108,18 +112,28 @@ struct kprobe {
108 /* copy of the original instruction */ 112 /* copy of the original instruction */
109 struct arch_specific_insn ainsn; 113 struct arch_specific_insn ainsn;
110 114
111 /* Indicates various status flags. Protected by kprobe_mutex. */ 115 /*
116 * Indicates various status flags.
117 * Protected by kprobe_mutex after this kprobe is registered.
118 */
112 u32 flags; 119 u32 flags;
113}; 120};
114 121
115/* Kprobe status flags */ 122/* Kprobe status flags */
116#define KPROBE_FLAG_GONE 1 /* breakpoint has already gone */ 123#define KPROBE_FLAG_GONE 1 /* breakpoint has already gone */
124#define KPROBE_FLAG_DISABLED 2 /* probe is temporarily disabled */
117 125
126/* Has this kprobe gone ? */
118static inline int kprobe_gone(struct kprobe *p) 127static inline int kprobe_gone(struct kprobe *p)
119{ 128{
120 return p->flags & KPROBE_FLAG_GONE; 129 return p->flags & KPROBE_FLAG_GONE;
121} 130}
122 131
132/* Is this kprobe disabled ? */
133static inline int kprobe_disabled(struct kprobe *p)
134{
135 return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE);
136}
123/* 137/*
124 * Special probe type that uses setjmp-longjmp type tricks to resume 138 * Special probe type that uses setjmp-longjmp type tricks to resume
125 * execution at a specified entry with a matching prototype corresponding 139 * execution at a specified entry with a matching prototype corresponding
@@ -182,6 +196,14 @@ struct kprobe_blackpoint {
182DECLARE_PER_CPU(struct kprobe *, current_kprobe); 196DECLARE_PER_CPU(struct kprobe *, current_kprobe);
183DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 197DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
184 198
199/*
200 * For #ifdef avoidance:
201 */
202static inline int kprobes_built_in(void)
203{
204 return 1;
205}
206
185#ifdef CONFIG_KRETPROBES 207#ifdef CONFIG_KRETPROBES
186extern void arch_prepare_kretprobe(struct kretprobe_instance *ri, 208extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
187 struct pt_regs *regs); 209 struct pt_regs *regs);
@@ -271,8 +293,19 @@ void unregister_kretprobes(struct kretprobe **rps, int num);
271void kprobe_flush_task(struct task_struct *tk); 293void kprobe_flush_task(struct task_struct *tk);
272void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head); 294void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
273 295
274#else /* CONFIG_KPROBES */ 296int disable_kprobe(struct kprobe *kp);
297int enable_kprobe(struct kprobe *kp);
275 298
299#else /* !CONFIG_KPROBES: */
300
301static inline int kprobes_built_in(void)
302{
303 return 0;
304}
305static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
306{
307 return 0;
308}
276static inline struct kprobe *get_kprobe(void *addr) 309static inline struct kprobe *get_kprobe(void *addr)
277{ 310{
278 return NULL; 311 return NULL;
@@ -329,5 +362,30 @@ static inline void unregister_kretprobes(struct kretprobe **rps, int num)
329static inline void kprobe_flush_task(struct task_struct *tk) 362static inline void kprobe_flush_task(struct task_struct *tk)
330{ 363{
331} 364}
332#endif /* CONFIG_KPROBES */ 365static inline int disable_kprobe(struct kprobe *kp)
333#endif /* _LINUX_KPROBES_H */ 366{
367 return -ENOSYS;
368}
369static inline int enable_kprobe(struct kprobe *kp)
370{
371 return -ENOSYS;
372}
373#endif /* CONFIG_KPROBES */
374static inline int disable_kretprobe(struct kretprobe *rp)
375{
376 return disable_kprobe(&rp->kp);
377}
378static inline int enable_kretprobe(struct kretprobe *rp)
379{
380 return enable_kprobe(&rp->kp);
381}
382static inline int disable_jprobe(struct jprobe *jp)
383{
384 return disable_kprobe(&jp->kp);
385}
386static inline int enable_jprobe(struct jprobe *jp)
387{
388 return enable_kprobe(&jp->kp);
389}
390
391#endif /* _LINUX_KPROBES_H */