2 * Kernel Probes (KProbes)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Copyright (C) IBM Corporation, 2002, 2004
21 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
22 * Probes initial implementation (includes suggestions from
24 * 2004-Aug Updated by Prasanna S Panchamukhi <prasanna@in.ibm.com> with
25 * hlists and exceptions notifier as suggested by Andi Kleen.
26 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
27 * interface to access function arguments.
28 * 2004-Sep Prasanna S Panchamukhi <prasanna@in.ibm.com> Changed Kprobes
29 * exceptions notifier to be first on the priority list.
30 * 2005-May Hien Nguyen <hien@us.ibm.com>, Jim Keniston
31 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
32 * <prasanna@in.ibm.com> added function-return probes.
34 #include <linux/kprobes.h>
35 #include <linux/hash.h>
36 #include <linux/init.h>
37 #include <linux/slab.h>
38 #include <linux/stddef.h>
39 #include <linux/module.h>
40 #include <linux/moduleloader.h>
41 #include <linux/kallsyms.h>
42 #include <linux/freezer.h>
43 #include <linux/seq_file.h>
44 #include <linux/debugfs.h>
45 #include <linux/kdebug.h>
46 #include <asm-generic/sections.h>
47 #include <asm/cacheflush.h>
48 #include <asm/errno.h>
50 #define KPROBE_HASH_BITS 6
51 #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
55 * Some oddball architectures like 64bit powerpc have function descriptors
56 * so this must be overridable.
58 #ifndef kprobe_lookup_name
59 #define kprobe_lookup_name(name, addr) \
60 addr = ((kprobe_opcode_t *)(kallsyms_lookup_name(name)))
63 static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
64 static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
65 static atomic_t kprobe_count;
67 DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
68 DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */
69 static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL;
71 static struct notifier_block kprobe_page_fault_nb = {
72 .notifier_call = kprobe_exceptions_notify,
73 .priority = 0x7fffffff /* we need to notified first */
76 #ifdef __ARCH_WANT_KPROBES_INSN_SLOT
78 * kprobe->ainsn.insn points to the copy of the instruction to be
79 * single-stepped. x86_64, POWER4 and above have no-exec support and
80 * stepping on the instruction on a vmalloced/kmalloced/data page
81 * is a recipe for disaster
83 #define INSNS_PER_PAGE (PAGE_SIZE/(MAX_INSN_SIZE * sizeof(kprobe_opcode_t)))
85 struct kprobe_insn_page {
86 struct hlist_node hlist;
87 kprobe_opcode_t *insns; /* Page of instruction slots */
88 char slot_used[INSNS_PER_PAGE];
93 enum kprobe_slot_state {
99 static struct hlist_head kprobe_insn_pages;
100 static int kprobe_garbage_slots;
101 static int collect_garbage_slots(void);
103 static int __kprobes check_safety(void)
106 #if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
107 ret = freeze_processes();
109 struct task_struct *p, *q;
110 do_each_thread(p, q) {
111 if (p != current && p->state == TASK_RUNNING &&
113 printk("Check failed: %s is running\n",p->comm);
117 } while_each_thread(p, q);
128 * get_insn_slot() - Find a slot on an executable page for an instruction.
129 * We allocate an executable page if there's no room on existing ones.
131 kprobe_opcode_t __kprobes *get_insn_slot(void)
133 struct kprobe_insn_page *kip;
134 struct hlist_node *pos;
137 hlist_for_each_entry(kip, pos, &kprobe_insn_pages, hlist) {
138 if (kip->nused < INSNS_PER_PAGE) {
140 for (i = 0; i < INSNS_PER_PAGE; i++) {
141 if (kip->slot_used[i] == SLOT_CLEAN) {
142 kip->slot_used[i] = SLOT_USED;
144 return kip->insns + (i * MAX_INSN_SIZE);
147 /* Surprise! No unused slots. Fix kip->nused. */
148 kip->nused = INSNS_PER_PAGE;
152 /* If there are any garbage slots, collect it and try again. */
153 if (kprobe_garbage_slots && collect_garbage_slots() == 0) {
156 /* All out of space. Need to allocate a new page. Use slot 0. */
157 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
162 * Use module_alloc so this page is within +/- 2GB of where the
163 * kernel image and loaded module images reside. This is required
164 * so x86_64 can correctly handle the %rip-relative fixups.
166 kip->insns = module_alloc(PAGE_SIZE);
171 INIT_HLIST_NODE(&kip->hlist);
172 hlist_add_head(&kip->hlist, &kprobe_insn_pages);
173 memset(kip->slot_used, SLOT_CLEAN, INSNS_PER_PAGE);
174 kip->slot_used[0] = SLOT_USED;
180 /* Return 1 if all garbages are collected, otherwise 0. */
181 static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
183 kip->slot_used[idx] = SLOT_CLEAN;
185 if (kip->nused == 0) {
187 * Page is no longer in use. Free it unless
188 * it's the last one. We keep the last one
189 * so as not to have to set it up again the
190 * next time somebody inserts a probe.
192 hlist_del(&kip->hlist);
193 if (hlist_empty(&kprobe_insn_pages)) {
194 INIT_HLIST_NODE(&kip->hlist);
195 hlist_add_head(&kip->hlist,
198 module_free(NULL, kip->insns);
206 static int __kprobes collect_garbage_slots(void)
208 struct kprobe_insn_page *kip;
209 struct hlist_node *pos, *next;
211 /* Ensure no-one is preepmted on the garbages */
212 if (check_safety() != 0)
215 hlist_for_each_entry_safe(kip, pos, next, &kprobe_insn_pages, hlist) {
217 if (kip->ngarbage == 0)
219 kip->ngarbage = 0; /* we will collect all garbages */
220 for (i = 0; i < INSNS_PER_PAGE; i++) {
221 if (kip->slot_used[i] == SLOT_DIRTY &&
222 collect_one_slot(kip, i))
226 kprobe_garbage_slots = 0;
230 void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
232 struct kprobe_insn_page *kip;
233 struct hlist_node *pos;
235 hlist_for_each_entry(kip, pos, &kprobe_insn_pages, hlist) {
236 if (kip->insns <= slot &&
237 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) {
238 int i = (slot - kip->insns) / MAX_INSN_SIZE;
240 kip->slot_used[i] = SLOT_DIRTY;
243 collect_one_slot(kip, i);
249 if (dirty && ++kprobe_garbage_slots > INSNS_PER_PAGE)
250 collect_garbage_slots();
254 /* We have preemption disabled.. so it is safe to use __ versions */
255 static inline void set_kprobe_instance(struct kprobe *kp)
257 __get_cpu_var(kprobe_instance) = kp;
260 static inline void reset_kprobe_instance(void)
262 __get_cpu_var(kprobe_instance) = NULL;
266 * This routine is called either:
267 * - under the kprobe_mutex - during kprobe_[un]register()
269 * - with preemption disabled - from arch/xxx/kernel/kprobes.c
271 struct kprobe __kprobes *get_kprobe(void *addr)
273 struct hlist_head *head;
274 struct hlist_node *node;
277 head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)];
278 hlist_for_each_entry_rcu(p, node, head, hlist) {
286 * Aggregate handlers for multiple kprobes support - these handlers
287 * take care of invoking the individual kprobe handlers on p->list
289 static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
293 list_for_each_entry_rcu(kp, &p->list, list) {
294 if (kp->pre_handler) {
295 set_kprobe_instance(kp);
296 if (kp->pre_handler(kp, regs))
299 reset_kprobe_instance();
304 static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
309 list_for_each_entry_rcu(kp, &p->list, list) {
310 if (kp->post_handler) {
311 set_kprobe_instance(kp);
312 kp->post_handler(kp, regs, flags);
313 reset_kprobe_instance();
318 static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
321 struct kprobe *cur = __get_cpu_var(kprobe_instance);
324 * if we faulted "during" the execution of a user specified
325 * probe handler, invoke just that probe's fault handler
327 if (cur && cur->fault_handler) {
328 if (cur->fault_handler(cur, regs, trapnr))
334 static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
336 struct kprobe *cur = __get_cpu_var(kprobe_instance);
339 if (cur && cur->break_handler) {
340 if (cur->break_handler(cur, regs))
343 reset_kprobe_instance();
347 /* Walks the list and increments nmissed count for multiprobe case */
348 void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
351 if (p->pre_handler != aggr_pre_handler) {
354 list_for_each_entry_rcu(kp, &p->list, list)
360 /* Called with kretprobe_lock held */
361 struct kretprobe_instance __kprobes *get_free_rp_inst(struct kretprobe *rp)
363 struct hlist_node *node;
364 struct kretprobe_instance *ri;
365 hlist_for_each_entry(ri, node, &rp->free_instances, uflist)
370 /* Called with kretprobe_lock held */
371 static struct kretprobe_instance __kprobes *get_used_rp_inst(struct kretprobe
374 struct hlist_node *node;
375 struct kretprobe_instance *ri;
376 hlist_for_each_entry(ri, node, &rp->used_instances, uflist)
381 /* Called with kretprobe_lock held */
382 void __kprobes add_rp_inst(struct kretprobe_instance *ri)
385 * Remove rp inst off the free list -
386 * Add it back when probed function returns
388 hlist_del(&ri->uflist);
390 /* Add rp inst onto table */
391 INIT_HLIST_NODE(&ri->hlist);
392 hlist_add_head(&ri->hlist,
393 &kretprobe_inst_table[hash_ptr(ri->task, KPROBE_HASH_BITS)]);
395 /* Also add this rp inst to the used list. */
396 INIT_HLIST_NODE(&ri->uflist);
397 hlist_add_head(&ri->uflist, &ri->rp->used_instances);
400 /* Called with kretprobe_lock held */
401 void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
402 struct hlist_head *head)
404 /* remove rp inst off the rprobe_inst_table */
405 hlist_del(&ri->hlist);
407 /* remove rp inst off the used list */
408 hlist_del(&ri->uflist);
409 /* put rp inst back onto the free list */
410 INIT_HLIST_NODE(&ri->uflist);
411 hlist_add_head(&ri->uflist, &ri->rp->free_instances);
414 hlist_add_head(&ri->hlist, head);
417 struct hlist_head __kprobes *kretprobe_inst_table_head(struct task_struct *tsk)
419 return &kretprobe_inst_table[hash_ptr(tsk, KPROBE_HASH_BITS)];
423 * This function is called from finish_task_switch when task tk becomes dead,
424 * so that we can recycle any function-return probe instances associated
425 * with this task. These left over instances represent probed functions
426 * that have been called but will never return.
428 void __kprobes kprobe_flush_task(struct task_struct *tk)
430 struct kretprobe_instance *ri;
431 struct hlist_head *head, empty_rp;
432 struct hlist_node *node, *tmp;
433 unsigned long flags = 0;
435 INIT_HLIST_HEAD(&empty_rp);
436 spin_lock_irqsave(&kretprobe_lock, flags);
437 head = kretprobe_inst_table_head(tk);
438 hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
440 recycle_rp_inst(ri, &empty_rp);
442 spin_unlock_irqrestore(&kretprobe_lock, flags);
444 hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
445 hlist_del(&ri->hlist);
450 static inline void free_rp_inst(struct kretprobe *rp)
452 struct kretprobe_instance *ri;
453 while ((ri = get_free_rp_inst(rp)) != NULL) {
454 hlist_del(&ri->uflist);
460 * Keep all fields in the kprobe consistent
462 static inline void copy_kprobe(struct kprobe *old_p, struct kprobe *p)
464 memcpy(&p->opcode, &old_p->opcode, sizeof(kprobe_opcode_t));
465 memcpy(&p->ainsn, &old_p->ainsn, sizeof(struct arch_specific_insn));
469 * Add the new probe to old_p->list. Fail if this is the
470 * second jprobe at the address - two jprobes can't coexist
472 static int __kprobes add_new_kprobe(struct kprobe *old_p, struct kprobe *p)
474 if (p->break_handler) {
475 if (old_p->break_handler)
477 list_add_tail_rcu(&p->list, &old_p->list);
478 old_p->break_handler = aggr_break_handler;
480 list_add_rcu(&p->list, &old_p->list);
481 if (p->post_handler && !old_p->post_handler)
482 old_p->post_handler = aggr_post_handler;
487 * Fill in the required fields of the "manager kprobe". Replace the
488 * earlier kprobe in the hlist with the manager kprobe
490 static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
495 ap->pre_handler = aggr_pre_handler;
496 ap->fault_handler = aggr_fault_handler;
498 ap->post_handler = aggr_post_handler;
499 if (p->break_handler)
500 ap->break_handler = aggr_break_handler;
502 INIT_LIST_HEAD(&ap->list);
503 list_add_rcu(&p->list, &ap->list);
505 hlist_replace_rcu(&p->hlist, &ap->hlist);
509 * This is the second or subsequent kprobe at the address - handle
512 static int __kprobes register_aggr_kprobe(struct kprobe *old_p,
518 if (old_p->pre_handler == aggr_pre_handler) {
519 copy_kprobe(old_p, p);
520 ret = add_new_kprobe(old_p, p);
522 ap = kzalloc(sizeof(struct kprobe), GFP_KERNEL);
525 add_aggr_kprobe(ap, old_p);
527 ret = add_new_kprobe(ap, p);
532 static int __kprobes in_kprobes_functions(unsigned long addr)
534 if (addr >= (unsigned long)__kprobes_text_start &&
535 addr < (unsigned long)__kprobes_text_end)
540 static int __kprobes __register_kprobe(struct kprobe *p,
541 unsigned long called_from)
544 struct kprobe *old_p;
545 struct module *probed_mod;
548 * If we have a symbol_name argument look it up,
549 * and add it to the address. That way the addr
550 * field can either be global or relative to a symbol.
552 if (p->symbol_name) {
555 kprobe_lookup_name(p->symbol_name, p->addr);
560 p->addr = (kprobe_opcode_t *)(((char *)p->addr)+ p->offset);
562 if (!kernel_text_address((unsigned long) p->addr) ||
563 in_kprobes_functions((unsigned long) p->addr))
566 p->mod_refcounted = 0;
569 * Check if are we probing a module.
571 probed_mod = module_text_address((unsigned long) p->addr);
573 struct module *calling_mod = module_text_address(called_from);
575 * We must allow modules to probe themself and in this case
576 * avoid incrementing the module refcount, so as to allow
577 * unloading of self probing modules.
579 if (calling_mod && calling_mod != probed_mod) {
580 if (unlikely(!try_module_get(probed_mod)))
582 p->mod_refcounted = 1;
588 mutex_lock(&kprobe_mutex);
589 old_p = get_kprobe(p->addr);
591 ret = register_aggr_kprobe(old_p, p);
593 atomic_inc(&kprobe_count);
597 ret = arch_prepare_kprobe(p);
601 INIT_HLIST_NODE(&p->hlist);
602 hlist_add_head_rcu(&p->hlist,
603 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
605 if (atomic_add_return(1, &kprobe_count) == \
606 (ARCH_INACTIVE_KPROBE_COUNT + 1))
607 register_page_fault_notifier(&kprobe_page_fault_nb);
612 mutex_unlock(&kprobe_mutex);
614 if (ret && probed_mod)
615 module_put(probed_mod);
619 int __kprobes register_kprobe(struct kprobe *p)
621 return __register_kprobe(p, (unsigned long)__builtin_return_address(0));
624 void __kprobes unregister_kprobe(struct kprobe *p)
627 struct kprobe *old_p, *list_p;
630 mutex_lock(&kprobe_mutex);
631 old_p = get_kprobe(p->addr);
632 if (unlikely(!old_p)) {
633 mutex_unlock(&kprobe_mutex);
637 list_for_each_entry_rcu(list_p, &old_p->list, list)
639 /* kprobe p is a valid probe */
641 mutex_unlock(&kprobe_mutex);
646 (old_p->pre_handler == aggr_pre_handler &&
647 p->list.next == &old_p->list && p->list.prev == &old_p->list)) {
648 /* Only probe on the hash list */
649 arch_disarm_kprobe(p);
650 hlist_del_rcu(&old_p->hlist);
653 list_del_rcu(&p->list);
657 mutex_unlock(&kprobe_mutex);
660 if (p->mod_refcounted) {
661 mod = module_text_address((unsigned long)p->addr);
668 list_del_rcu(&p->list);
671 arch_remove_kprobe(p);
673 mutex_lock(&kprobe_mutex);
674 if (p->break_handler)
675 old_p->break_handler = NULL;
676 if (p->post_handler){
677 list_for_each_entry_rcu(list_p, &old_p->list, list){
678 if (list_p->post_handler){
684 old_p->post_handler = NULL;
686 mutex_unlock(&kprobe_mutex);
689 /* Call unregister_page_fault_notifier()
690 * if no probes are active
692 mutex_lock(&kprobe_mutex);
693 if (atomic_add_return(-1, &kprobe_count) == \
694 ARCH_INACTIVE_KPROBE_COUNT)
695 unregister_page_fault_notifier(&kprobe_page_fault_nb);
696 mutex_unlock(&kprobe_mutex);
700 static struct notifier_block kprobe_exceptions_nb = {
701 .notifier_call = kprobe_exceptions_notify,
702 .priority = 0x7fffffff /* we need to be notified first */
706 int __kprobes register_jprobe(struct jprobe *jp)
708 /* Todo: Verify probepoint is a function entry point */
709 jp->kp.pre_handler = setjmp_pre_handler;
710 jp->kp.break_handler = longjmp_break_handler;
712 return __register_kprobe(&jp->kp,
713 (unsigned long)__builtin_return_address(0));
716 void __kprobes unregister_jprobe(struct jprobe *jp)
718 unregister_kprobe(&jp->kp);
721 #ifdef ARCH_SUPPORTS_KRETPROBES
724 * This kprobe pre_handler is registered with every kretprobe. When probe
725 * hits it will set up the return probe.
727 static int __kprobes pre_handler_kretprobe(struct kprobe *p,
728 struct pt_regs *regs)
730 struct kretprobe *rp = container_of(p, struct kretprobe, kp);
731 unsigned long flags = 0;
733 /*TODO: consider to only swap the RA after the last pre_handler fired */
734 spin_lock_irqsave(&kretprobe_lock, flags);
735 arch_prepare_kretprobe(rp, regs);
736 spin_unlock_irqrestore(&kretprobe_lock, flags);
740 int __kprobes register_kretprobe(struct kretprobe *rp)
743 struct kretprobe_instance *inst;
746 rp->kp.pre_handler = pre_handler_kretprobe;
747 rp->kp.post_handler = NULL;
748 rp->kp.fault_handler = NULL;
749 rp->kp.break_handler = NULL;
751 /* Pre-allocate memory for max kretprobe instances */
752 if (rp->maxactive <= 0) {
753 #ifdef CONFIG_PREEMPT
754 rp->maxactive = max(10, 2 * NR_CPUS);
756 rp->maxactive = NR_CPUS;
759 INIT_HLIST_HEAD(&rp->used_instances);
760 INIT_HLIST_HEAD(&rp->free_instances);
761 for (i = 0; i < rp->maxactive; i++) {
762 inst = kmalloc(sizeof(struct kretprobe_instance), GFP_KERNEL);
767 INIT_HLIST_NODE(&inst->uflist);
768 hlist_add_head(&inst->uflist, &rp->free_instances);
772 /* Establish function entry probe point */
773 if ((ret = __register_kprobe(&rp->kp,
774 (unsigned long)__builtin_return_address(0))) != 0)
779 #else /* ARCH_SUPPORTS_KRETPROBES */
781 int __kprobes register_kretprobe(struct kretprobe *rp)
786 static int __kprobes pre_handler_kretprobe(struct kprobe *p,
787 struct pt_regs *regs)
792 #endif /* ARCH_SUPPORTS_KRETPROBES */
794 void __kprobes unregister_kretprobe(struct kretprobe *rp)
797 struct kretprobe_instance *ri;
799 unregister_kprobe(&rp->kp);
801 spin_lock_irqsave(&kretprobe_lock, flags);
802 while ((ri = get_used_rp_inst(rp)) != NULL) {
804 hlist_del(&ri->uflist);
806 spin_unlock_irqrestore(&kretprobe_lock, flags);
810 static int __init init_kprobes(void)
814 /* FIXME allocate the probe table, currently defined statically */
815 /* initialize all list heads */
816 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
817 INIT_HLIST_HEAD(&kprobe_table[i]);
818 INIT_HLIST_HEAD(&kretprobe_inst_table[i]);
820 atomic_set(&kprobe_count, 0);
822 err = arch_init_kprobes();
824 err = register_die_notifier(&kprobe_exceptions_nb);
829 #ifdef CONFIG_DEBUG_FS
830 static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
831 const char *sym, int offset,char *modname)
835 if (p->pre_handler == pre_handler_kretprobe)
837 else if (p->pre_handler == setjmp_pre_handler)
842 seq_printf(pi, "%p %s %s+0x%x %s\n", p->addr, kprobe_type,
843 sym, offset, (modname ? modname : " "));
845 seq_printf(pi, "%p %s %p\n", p->addr, kprobe_type, p->addr);
848 static void __kprobes *kprobe_seq_start(struct seq_file *f, loff_t *pos)
850 return (*pos < KPROBE_TABLE_SIZE) ? pos : NULL;
853 static void __kprobes *kprobe_seq_next(struct seq_file *f, void *v, loff_t *pos)
856 if (*pos >= KPROBE_TABLE_SIZE)
861 static void __kprobes kprobe_seq_stop(struct seq_file *f, void *v)
866 static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
868 struct hlist_head *head;
869 struct hlist_node *node;
870 struct kprobe *p, *kp;
871 const char *sym = NULL;
872 unsigned int i = *(loff_t *) v;
873 unsigned long offset = 0;
874 char *modname, namebuf[128];
876 head = &kprobe_table[i];
878 hlist_for_each_entry_rcu(p, node, head, hlist) {
879 sym = kallsyms_lookup((unsigned long)p->addr, NULL,
880 &offset, &modname, namebuf);
881 if (p->pre_handler == aggr_pre_handler) {
882 list_for_each_entry_rcu(kp, &p->list, list)
883 report_probe(pi, kp, sym, offset, modname);
885 report_probe(pi, p, sym, offset, modname);
891 static struct seq_operations kprobes_seq_ops = {
892 .start = kprobe_seq_start,
893 .next = kprobe_seq_next,
894 .stop = kprobe_seq_stop,
895 .show = show_kprobe_addr
898 static int __kprobes kprobes_open(struct inode *inode, struct file *filp)
900 return seq_open(filp, &kprobes_seq_ops);
903 static struct file_operations debugfs_kprobes_operations = {
904 .open = kprobes_open,
907 .release = seq_release,
910 static int __kprobes debugfs_kprobe_init(void)
912 struct dentry *dir, *file;
914 dir = debugfs_create_dir("kprobes", NULL);
918 file = debugfs_create_file("list", 0444, dir, NULL,
919 &debugfs_kprobes_operations);
928 late_initcall(debugfs_kprobe_init);
929 #endif /* CONFIG_DEBUG_FS */
931 module_init(init_kprobes);
933 EXPORT_SYMBOL_GPL(register_kprobe);
934 EXPORT_SYMBOL_GPL(unregister_kprobe);
935 EXPORT_SYMBOL_GPL(register_jprobe);
936 EXPORT_SYMBOL_GPL(unregister_jprobe);
937 EXPORT_SYMBOL_GPL(jprobe_return);
938 EXPORT_SYMBOL_GPL(register_kretprobe);
939 EXPORT_SYMBOL_GPL(unregister_kretprobe);