diff options
| author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-04-06 22:01:02 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-07 11:31:08 -0400 |
| commit | de5bd88d5a5cce3cacea904d3503e5ebdb3852a2 (patch) | |
| tree | da24ac8b38d371ee03a21ed0f3647c518689ebd3 /include/linux | |
| parent | e579abeb58eb4b8d7321c6eb44dd9e2d0cbaebaa (diff) | |
kprobes: support per-kprobe disabling
Add disable_kprobe() and enable_kprobe() to disable/enable kprobes
temporarily.
disable_kprobe() asynchronously disables probe handlers of specified
kprobe. So, after calling it, some handlers can be called at a while.
enable_kprobe() enables specified kprobe.
aggr_pre_handler and aggr_post_handler check disabled probes. On the
other hand aggr_break_handler and aggr_fault_handler don't check it
because these handlers will be called while executing pre or post handlers
and usually those help error handling.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/kprobes.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 39826a678364..1071cfddddc9 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
| @@ -112,18 +112,28 @@ struct kprobe { | |||
| 112 | /* copy of the original instruction */ | 112 | /* copy of the original instruction */ |
| 113 | struct arch_specific_insn ainsn; | 113 | struct arch_specific_insn ainsn; |
| 114 | 114 | ||
| 115 | /* 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 | */ | ||
| 116 | u32 flags; | 119 | u32 flags; |
| 117 | }; | 120 | }; |
| 118 | 121 | ||
| 119 | /* Kprobe status flags */ | 122 | /* Kprobe status flags */ |
| 120 | #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 */ | ||
| 121 | 125 | ||
| 126 | /* Has this kprobe gone ? */ | ||
| 122 | static inline int kprobe_gone(struct kprobe *p) | 127 | static inline int kprobe_gone(struct kprobe *p) |
| 123 | { | 128 | { |
| 124 | return p->flags & KPROBE_FLAG_GONE; | 129 | return p->flags & KPROBE_FLAG_GONE; |
| 125 | } | 130 | } |
| 126 | 131 | ||
| 132 | /* Is this kprobe disabled ? */ | ||
| 133 | static inline int kprobe_disabled(struct kprobe *p) | ||
| 134 | { | ||
| 135 | return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE); | ||
| 136 | } | ||
| 127 | /* | 137 | /* |
| 128 | * Special probe type that uses setjmp-longjmp type tricks to resume | 138 | * Special probe type that uses setjmp-longjmp type tricks to resume |
| 129 | * execution at a specified entry with a matching prototype corresponding | 139 | * execution at a specified entry with a matching prototype corresponding |
| @@ -283,6 +293,9 @@ void unregister_kretprobes(struct kretprobe **rps, int num); | |||
| 283 | void kprobe_flush_task(struct task_struct *tk); | 293 | void kprobe_flush_task(struct task_struct *tk); |
| 284 | void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head); | 294 | void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head); |
| 285 | 295 | ||
| 296 | int disable_kprobe(struct kprobe *kp); | ||
| 297 | int enable_kprobe(struct kprobe *kp); | ||
| 298 | |||
| 286 | #else /* !CONFIG_KPROBES: */ | 299 | #else /* !CONFIG_KPROBES: */ |
| 287 | 300 | ||
| 288 | static inline int kprobes_built_in(void) | 301 | static inline int kprobes_built_in(void) |
| @@ -349,5 +362,13 @@ static inline void unregister_kretprobes(struct kretprobe **rps, int num) | |||
| 349 | static inline void kprobe_flush_task(struct task_struct *tk) | 362 | static inline void kprobe_flush_task(struct task_struct *tk) |
| 350 | { | 363 | { |
| 351 | } | 364 | } |
| 365 | static inline int disable_kprobe(struct kprobe *kp) | ||
| 366 | { | ||
| 367 | return -ENOSYS; | ||
| 368 | } | ||
| 369 | static inline int enable_kprobe(struct kprobe *kp) | ||
| 370 | { | ||
| 371 | return -ENOSYS; | ||
| 372 | } | ||
| 352 | #endif /* CONFIG_KPROBES */ | 373 | #endif /* CONFIG_KPROBES */ |
| 353 | #endif /* _LINUX_KPROBES_H */ | 374 | #endif /* _LINUX_KPROBES_H */ |
