Lines Matching refs:p
367 struct kprobe *p; in get_kprobe() local
370 hlist_for_each_entry_rcu(p, head, hlist, in get_kprobe()
372 if (p->addr == addr) in get_kprobe()
373 return p; in get_kprobe()
380 static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs);
383 static inline int kprobe_aggrprobe(struct kprobe *p) in kprobe_aggrprobe() argument
385 return p->pre_handler == aggr_pre_handler; in kprobe_aggrprobe()
389 static inline int kprobe_unused(struct kprobe *p) in kprobe_unused() argument
391 return kprobe_aggrprobe(p) && kprobe_disabled(p) && in kprobe_unused()
392 list_empty(&p->list); in kprobe_unused()
398 static inline void copy_kprobe(struct kprobe *ap, struct kprobe *p) in copy_kprobe() argument
400 memcpy(&p->opcode, &ap->opcode, sizeof(kprobe_opcode_t)); in copy_kprobe()
401 memcpy(&p->ainsn, &ap->ainsn, sizeof(struct arch_specific_insn)); in copy_kprobe()
412 void opt_pre_handler(struct kprobe *p, struct pt_regs *regs) in opt_pre_handler() argument
416 list_for_each_entry_rcu(kp, &p->list, list) { in opt_pre_handler()
427 static void free_aggr_kprobe(struct kprobe *p) in free_aggr_kprobe() argument
431 op = container_of(p, struct optimized_kprobe, kp); in free_aggr_kprobe()
433 arch_remove_kprobe(p); in free_aggr_kprobe()
438 static inline int kprobe_optready(struct kprobe *p) in kprobe_optready() argument
442 if (kprobe_aggrprobe(p)) { in kprobe_optready()
443 op = container_of(p, struct optimized_kprobe, kp); in kprobe_optready()
451 bool kprobe_disarmed(struct kprobe *p) in kprobe_disarmed() argument
456 if (!kprobe_aggrprobe(p)) in kprobe_disarmed()
457 return kprobe_disabled(p); in kprobe_disarmed()
459 op = container_of(p, struct optimized_kprobe, kp); in kprobe_disarmed()
461 return kprobe_disabled(p) && list_empty(&op->list); in kprobe_disarmed()
465 static int kprobe_queued(struct kprobe *p) in kprobe_queued() argument
469 if (kprobe_aggrprobe(p)) { in kprobe_queued()
470 op = container_of(p, struct optimized_kprobe, kp); in kprobe_queued()
484 struct kprobe *p = NULL; in get_optimized_kprobe() local
488 for (i = 1; !p && i < MAX_OPTIMIZED_LENGTH; i++) in get_optimized_kprobe()
489 p = get_kprobe((void *)(addr - i)); in get_optimized_kprobe()
491 if (p && kprobe_optready(p)) { in get_optimized_kprobe()
492 op = container_of(p, struct optimized_kprobe, kp); in get_optimized_kprobe()
494 return p; in get_optimized_kprobe()
666 static void optimize_kprobe(struct kprobe *p) in optimize_kprobe() argument
671 if (!kprobe_optready(p) || !kprobes_allow_optimization || in optimize_kprobe()
672 (kprobe_disabled(p) || kprobes_all_disarmed)) in optimize_kprobe()
676 if (p->post_handler) in optimize_kprobe()
679 op = container_of(p, struct optimized_kprobe, kp); in optimize_kprobe()
712 static void unoptimize_kprobe(struct kprobe *p, bool force) in unoptimize_kprobe() argument
716 if (!kprobe_aggrprobe(p) || kprobe_disarmed(p)) in unoptimize_kprobe()
719 op = container_of(p, struct optimized_kprobe, kp); in unoptimize_kprobe()
720 if (!kprobe_optimized(p)) in unoptimize_kprobe()
774 static void kill_optimized_kprobe(struct kprobe *p) in kill_optimized_kprobe() argument
778 op = container_of(p, struct optimized_kprobe, kp); in kill_optimized_kprobe()
784 if (kprobe_unused(p)) { in kill_optimized_kprobe()
799 void __prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p) in __prepare_optimized_kprobe() argument
801 if (!kprobe_ftrace(p)) in __prepare_optimized_kprobe()
802 arch_prepare_optimized_kprobe(op, p); in __prepare_optimized_kprobe()
806 static void prepare_optimized_kprobe(struct kprobe *p) in prepare_optimized_kprobe() argument
810 op = container_of(p, struct optimized_kprobe, kp); in prepare_optimized_kprobe()
811 __prepare_optimized_kprobe(op, p); in prepare_optimized_kprobe()
815 static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) in alloc_aggr_kprobe() argument
824 op->kp.addr = p->addr; in alloc_aggr_kprobe()
825 __prepare_optimized_kprobe(op, p); in alloc_aggr_kprobe()
830 static void init_aggr_kprobe(struct kprobe *ap, struct kprobe *p);
836 static void try_to_optimize_kprobe(struct kprobe *p) in try_to_optimize_kprobe() argument
842 if (kprobe_ftrace(p)) in try_to_optimize_kprobe()
850 ap = alloc_aggr_kprobe(p); in try_to_optimize_kprobe()
862 init_aggr_kprobe(ap, p); in try_to_optimize_kprobe()
874 struct kprobe *p; in optimize_all_kprobes() local
886 hlist_for_each_entry(p, head, hlist) in optimize_all_kprobes()
887 if (!kprobe_disabled(p)) in optimize_all_kprobes()
888 optimize_kprobe(p); in optimize_all_kprobes()
900 struct kprobe *p; in unoptimize_all_kprobes() local
914 hlist_for_each_entry(p, head, hlist) { in unoptimize_all_kprobes()
915 if (!kprobe_disabled(p)) in unoptimize_all_kprobes()
916 unoptimize_kprobe(p, false); in unoptimize_all_kprobes()
950 static void __arm_kprobe(struct kprobe *p) in __arm_kprobe() argument
955 _p = get_optimized_kprobe((unsigned long)p->addr); in __arm_kprobe()
960 arch_arm_kprobe(p); in __arm_kprobe()
961 optimize_kprobe(p); /* Try to optimize (add kprobe to a list) */ in __arm_kprobe()
965 static void __disarm_kprobe(struct kprobe *p, bool reopt) in __disarm_kprobe() argument
970 unoptimize_kprobe(p, kprobes_all_disarmed); in __disarm_kprobe()
972 if (!kprobe_queued(p)) { in __disarm_kprobe()
973 arch_disarm_kprobe(p); in __disarm_kprobe()
975 _p = get_optimized_kprobe((unsigned long)p->addr); in __disarm_kprobe()
984 #define optimize_kprobe(p) do {} while (0) argument
985 #define unoptimize_kprobe(p, f) do {} while (0) argument
986 #define kill_optimized_kprobe(p) do {} while (0) argument
987 #define prepare_optimized_kprobe(p) do {} while (0) argument
988 #define try_to_optimize_kprobe(p) do {} while (0) argument
989 #define __arm_kprobe(p) arch_arm_kprobe(p) argument
990 #define __disarm_kprobe(p, o) arch_disarm_kprobe(p) argument
991 #define kprobe_disarmed(p) kprobe_disabled(p) argument
1006 static void free_aggr_kprobe(struct kprobe *p) in free_aggr_kprobe() argument
1008 arch_remove_kprobe(p); in free_aggr_kprobe()
1009 kfree(p); in free_aggr_kprobe()
1012 static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) in alloc_aggr_kprobe() argument
1033 static int prepare_kprobe(struct kprobe *p) in prepare_kprobe() argument
1035 if (!kprobe_ftrace(p)) in prepare_kprobe()
1036 return arch_prepare_kprobe(p); in prepare_kprobe()
1038 return arch_prepare_kprobe_ftrace(p); in prepare_kprobe()
1042 static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, in __arm_kprobe_ftrace() argument
1047 ret = ftrace_set_filter_ip(ops, (unsigned long)p->addr, 0, 0); in __arm_kprobe_ftrace()
1050 p->addr, ret); in __arm_kprobe_ftrace()
1070 ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0); in __arm_kprobe_ftrace()
1074 static int arm_kprobe_ftrace(struct kprobe *p) in arm_kprobe_ftrace() argument
1076 bool ipmodify = (p->post_handler != NULL); in arm_kprobe_ftrace()
1078 return __arm_kprobe_ftrace(p, in arm_kprobe_ftrace()
1084 static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, in __disarm_kprobe_ftrace() argument
1097 ret = ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0); in __disarm_kprobe_ftrace()
1099 p->addr, ret); in __disarm_kprobe_ftrace()
1103 static int disarm_kprobe_ftrace(struct kprobe *p) in disarm_kprobe_ftrace() argument
1105 bool ipmodify = (p->post_handler != NULL); in disarm_kprobe_ftrace()
1107 return __disarm_kprobe_ftrace(p, in disarm_kprobe_ftrace()
1112 static inline int prepare_kprobe(struct kprobe *p) in prepare_kprobe() argument
1114 return arch_prepare_kprobe(p); in prepare_kprobe()
1117 static inline int arm_kprobe_ftrace(struct kprobe *p) in arm_kprobe_ftrace() argument
1122 static inline int disarm_kprobe_ftrace(struct kprobe *p) in disarm_kprobe_ftrace() argument
1162 static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs) in aggr_pre_handler() argument
1166 list_for_each_entry_rcu(kp, &p->list, list) { in aggr_pre_handler()
1178 static void aggr_post_handler(struct kprobe *p, struct pt_regs *regs, in aggr_post_handler() argument
1183 list_for_each_entry_rcu(kp, &p->list, list) { in aggr_post_handler()
1193 static int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, in aggr_fault_handler() argument
1211 void kprobes_inc_nmissed_count(struct kprobe *p) in kprobes_inc_nmissed_count() argument
1214 if (!kprobe_aggrprobe(p)) { in kprobes_inc_nmissed_count()
1215 p->nmissed++; in kprobes_inc_nmissed_count()
1217 list_for_each_entry_rcu(kp, &p->list, list) in kprobes_inc_nmissed_count()
1383 static int add_new_kprobe(struct kprobe *ap, struct kprobe *p) in add_new_kprobe() argument
1385 if (p->post_handler) in add_new_kprobe()
1388 list_add_rcu(&p->list, &ap->list); in add_new_kprobe()
1389 if (p->post_handler && !ap->post_handler) in add_new_kprobe()
1399 static void init_aggr_kprobe(struct kprobe *ap, struct kprobe *p) in init_aggr_kprobe() argument
1402 copy_kprobe(p, ap); in init_aggr_kprobe()
1404 ap->addr = p->addr; in init_aggr_kprobe()
1405 ap->flags = p->flags & ~KPROBE_FLAG_OPTIMIZED; in init_aggr_kprobe()
1409 if (p->post_handler && !kprobe_gone(p)) in init_aggr_kprobe()
1415 list_add_rcu(&p->list, &ap->list); in init_aggr_kprobe()
1416 hlist_replace_rcu(&p->hlist, &ap->hlist); in init_aggr_kprobe()
1423 static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p) in register_aggr_kprobe() argument
1477 copy_kprobe(ap, p); in register_aggr_kprobe()
1478 ret = add_new_kprobe(ap, p); in register_aggr_kprobe()
1485 if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) { in register_aggr_kprobe()
1492 list_del_rcu(&p->list); in register_aggr_kprobe()
1526 char symname[KSYM_NAME_LEN], *p; in within_kprobe_blacklist() local
1533 p = strchr(symname, '.'); in within_kprobe_blacklist()
1534 if (!p) in within_kprobe_blacklist()
1536 *p = '\0'; in within_kprobe_blacklist()
1570 static kprobe_opcode_t *kprobe_addr(struct kprobe *p) in kprobe_addr() argument
1572 return _kprobe_addr(p->addr, p->symbol_name, p->offset); in kprobe_addr()
1576 static struct kprobe *__get_valid_kprobe(struct kprobe *p) in __get_valid_kprobe() argument
1582 ap = get_kprobe(p->addr); in __get_valid_kprobe()
1586 if (p != ap) { in __get_valid_kprobe()
1588 if (list_p == p) in __get_valid_kprobe()
1598 static inline int check_kprobe_rereg(struct kprobe *p) in check_kprobe_rereg() argument
1603 if (__get_valid_kprobe(p)) in check_kprobe_rereg()
1610 int __weak arch_check_ftrace_location(struct kprobe *p) in arch_check_ftrace_location() argument
1614 ftrace_addr = ftrace_location((unsigned long)p->addr); in arch_check_ftrace_location()
1618 if ((unsigned long)p->addr != ftrace_addr) in arch_check_ftrace_location()
1620 p->flags |= KPROBE_FLAG_FTRACE; in arch_check_ftrace_location()
1639 static int check_kprobe_address_safe(struct kprobe *p, in check_kprobe_address_safe() argument
1644 ret = arch_check_ftrace_location(p); in check_kprobe_address_safe()
1651 if (!(core_kernel_text((unsigned long) p->addr) || in check_kprobe_address_safe()
1652 is_module_text_address((unsigned long) p->addr)) || in check_kprobe_address_safe()
1653 in_gate_area_no_mm((unsigned long) p->addr) || in check_kprobe_address_safe()
1654 within_kprobe_blacklist((unsigned long) p->addr) || in check_kprobe_address_safe()
1655 jump_label_text_reserved(p->addr, p->addr) || in check_kprobe_address_safe()
1656 static_call_text_reserved(p->addr, p->addr) || in check_kprobe_address_safe()
1657 find_bug((unsigned long)p->addr) || in check_kprobe_address_safe()
1658 is_cfi_preamble_symbol((unsigned long)p->addr)) { in check_kprobe_address_safe()
1664 *probed_mod = __module_text_address((unsigned long) p->addr); in check_kprobe_address_safe()
1679 if (within_module_init((unsigned long)p->addr, *probed_mod) && in check_kprobe_address_safe()
1693 int register_kprobe(struct kprobe *p) in register_kprobe() argument
1701 addr = kprobe_addr(p); in register_kprobe()
1704 p->addr = addr; in register_kprobe()
1706 ret = check_kprobe_rereg(p); in register_kprobe()
1711 p->flags &= KPROBE_FLAG_DISABLED; in register_kprobe()
1712 p->nmissed = 0; in register_kprobe()
1713 INIT_LIST_HEAD(&p->list); in register_kprobe()
1715 ret = check_kprobe_address_safe(p, &probed_mod); in register_kprobe()
1721 old_p = get_kprobe(p->addr); in register_kprobe()
1724 ret = register_aggr_kprobe(old_p, p); in register_kprobe()
1731 ret = prepare_kprobe(p); in register_kprobe()
1737 INIT_HLIST_NODE(&p->hlist); in register_kprobe()
1738 hlist_add_head_rcu(&p->hlist, in register_kprobe()
1739 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); in register_kprobe()
1741 if (!kprobes_all_disarmed && !kprobe_disabled(p)) { in register_kprobe()
1742 ret = arm_kprobe(p); in register_kprobe()
1744 hlist_del_rcu(&p->hlist); in register_kprobe()
1751 try_to_optimize_kprobe(p); in register_kprobe()
1781 static struct kprobe *__disable_kprobe(struct kprobe *p) in __disable_kprobe() argument
1787 orig_p = __get_valid_kprobe(p); in __disable_kprobe()
1791 if (!kprobe_disabled(p)) { in __disable_kprobe()
1793 if (p != orig_p) in __disable_kprobe()
1794 p->flags |= KPROBE_FLAG_DISABLED; in __disable_kprobe()
1797 if (p == orig_p || aggr_kprobe_disabled(orig_p)) { in __disable_kprobe()
1807 p->flags &= ~KPROBE_FLAG_DISABLED; in __disable_kprobe()
1821 static int __unregister_kprobe_top(struct kprobe *p) in __unregister_kprobe_top() argument
1826 ap = __disable_kprobe(p); in __unregister_kprobe_top()
1830 if (ap == p) in __unregister_kprobe_top()
1848 if (p->post_handler && !kprobe_gone(p)) { in __unregister_kprobe_top()
1850 if ((list_p != p) && (list_p->post_handler)) in __unregister_kprobe_top()
1866 list_del_rcu(&p->list); in __unregister_kprobe_top()
1881 static void __unregister_kprobe_bottom(struct kprobe *p) in __unregister_kprobe_bottom() argument
1885 if (list_empty(&p->list)) in __unregister_kprobe_bottom()
1887 arch_remove_kprobe(p); in __unregister_kprobe_bottom()
1888 else if (list_is_singular(&p->list)) { in __unregister_kprobe_bottom()
1890 ap = list_entry(p->list.next, struct kprobe, list); in __unregister_kprobe_bottom()
1891 list_del(&p->list); in __unregister_kprobe_bottom()
1915 void unregister_kprobe(struct kprobe *p) in unregister_kprobe() argument
1917 unregister_kprobes(&p, 1); in unregister_kprobe()
2053 static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) in NOKPROBE_SYMBOL()
2055 struct kretprobe *rp = container_of(p, struct kretprobe, kp); in NOKPROBE_SYMBOL()
2264 static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) in pre_handler_kretprobe() argument
2273 static void kill_kprobe(struct kprobe *p) in kill_kprobe() argument
2279 if (WARN_ON_ONCE(kprobe_gone(p))) in kill_kprobe()
2282 p->flags |= KPROBE_FLAG_GONE; in kill_kprobe()
2283 if (kprobe_aggrprobe(p)) { in kill_kprobe()
2288 list_for_each_entry(kp, &p->list, list) in kill_kprobe()
2290 p->post_handler = NULL; in kill_kprobe()
2291 kill_optimized_kprobe(p); in kill_kprobe()
2297 arch_remove_kprobe(p); in kill_kprobe()
2304 if (kprobe_ftrace(p) && !kprobe_disabled(p) && !kprobes_all_disarmed) in kill_kprobe()
2305 disarm_kprobe_ftrace(p); in kill_kprobe()
2312 struct kprobe *p; in disable_kprobe() local
2317 p = __disable_kprobe(kp); in disable_kprobe()
2318 if (IS_ERR(p)) in disable_kprobe()
2319 ret = PTR_ERR(p); in disable_kprobe()
2330 struct kprobe *p; in enable_kprobe() local
2335 p = __get_valid_kprobe(kp); in enable_kprobe()
2336 if (unlikely(p == NULL)) { in enable_kprobe()
2347 if (p != kp) in enable_kprobe()
2350 if (!kprobes_all_disarmed && kprobe_disabled(p)) { in enable_kprobe()
2351 p->flags &= ~KPROBE_FLAG_DISABLED; in enable_kprobe()
2352 ret = arm_kprobe(p); in enable_kprobe()
2354 p->flags |= KPROBE_FLAG_DISABLED; in enable_kprobe()
2355 if (p != kp) in enable_kprobe()
2544 struct kprobe *p; in kprobes_module_callback() local
2565 hlist_for_each_entry(p, head, hlist) { in kprobes_module_callback()
2566 if (kprobe_gone(p)) in kprobes_module_callback()
2569 if (within_module_init((unsigned long)p->addr, mod) || in kprobes_module_callback()
2571 within_module_core((unsigned long)p->addr, mod))) { in kprobes_module_callback()
2583 kill_kprobe(p); in kprobes_module_callback()
2607 struct kprobe *p; in kprobe_free_init_mem() local
2615 hlist_for_each_entry(p, head, hlist) { in kprobe_free_init_mem()
2616 if (start <= (void *)p->addr && (void *)p->addr < end) in kprobe_free_init_mem()
2617 kill_kprobe(p); in kprobe_free_init_mem()
2692 static void report_probe(struct seq_file *pi, struct kprobe *p, in report_probe() argument
2696 void *addr = p->addr; in report_probe()
2698 if (p->pre_handler == pre_handler_kretprobe) in report_probe()
2712 addr, kprobe_type, p->addr); in report_probe()
2715 pp = p; in report_probe()
2717 (kprobe_gone(p) ? "[GONE]" : ""), in report_probe()
2718 ((kprobe_disabled(p) && !kprobe_gone(p)) ? "[DISABLED]" : ""), in report_probe()
2744 struct kprobe *p, *kp; in show_kprobe_addr() local
2752 hlist_for_each_entry_rcu(p, head, hlist) { in show_kprobe_addr()
2753 sym = kallsyms_lookup((unsigned long)p->addr, NULL, in show_kprobe_addr()
2755 if (kprobe_aggrprobe(p)) { in show_kprobe_addr()
2756 list_for_each_entry_rcu(kp, &p->list, list) in show_kprobe_addr()
2757 report_probe(pi, kp, sym, offset, modname, p); in show_kprobe_addr()
2759 report_probe(pi, p, sym, offset, modname, NULL); in show_kprobe_addr()
2820 struct kprobe *p; in arm_all_kprobes() local
2840 hlist_for_each_entry(p, head, hlist) { in arm_all_kprobes()
2841 if (!kprobe_disabled(p)) { in arm_all_kprobes()
2842 err = arm_kprobe(p); in arm_all_kprobes()
2866 struct kprobe *p; in disarm_all_kprobes() local
2883 hlist_for_each_entry(p, head, hlist) { in disarm_all_kprobes()
2884 if (!arch_trampoline_kprobe(p) && !kprobe_disabled(p)) { in disarm_all_kprobes()
2885 err = disarm_kprobe(p, false); in disarm_all_kprobes()