33#define _LINUX_KPROBES_H
44/*
55 * Kernel Probes (KProbes)
6- * include/linux/kprobes.h
76 *
87 * Copyright (C) IBM Corporation, 2002, 2004
98 *
3938#define KPROBE_REENTER 0x00000004
4039#define KPROBE_HIT_SSDONE 0x00000008
4140
42- #else /* CONFIG_KPROBES */
41+ #else /* ! CONFIG_KPROBES */
4342#include <asm-generic/kprobes.h>
4443typedef int kprobe_opcode_t ;
4544struct arch_specific_insn {
@@ -228,7 +227,7 @@ static nokprobe_inline struct kretprobe *get_kretprobe(struct kretprobe_instance
228227 return READ_ONCE (ri -> rph -> rp );
229228}
230229
231- #else /* CONFIG_KRETPROBES */
230+ #else /* ! CONFIG_KRETPROBES */
232231static inline void arch_prepare_kretprobe (struct kretprobe * rp ,
233232 struct pt_regs * regs )
234233{
@@ -239,11 +238,15 @@ static inline int arch_trampoline_kprobe(struct kprobe *p)
239238}
240239#endif /* CONFIG_KRETPROBES */
241240
241+ /* Markers of '_kprobe_blacklist' section */
242+ extern unsigned long __start_kprobe_blacklist [];
243+ extern unsigned long __stop_kprobe_blacklist [];
244+
242245extern struct kretprobe_blackpoint kretprobe_blacklist [];
243246
244247#ifdef CONFIG_KPROBES_SANITY_TEST
245248extern int init_test_probes (void );
246- #else
249+ #else /* !CONFIG_KPROBES_SANITY_TEST */
247250static inline int init_test_probes (void )
248251{
249252 return 0 ;
@@ -303,7 +306,7 @@ static inline bool is_kprobe_##__name##_slot(unsigned long addr) \
303306#define KPROBE_OPTINSN_PAGE_SYM "kprobe_optinsn_page"
304307int kprobe_cache_get_kallsym (struct kprobe_insn_cache * c , unsigned int * symnum ,
305308 unsigned long * value , char * type , char * sym );
306- #else /* __ARCH_WANT_KPROBES_INSN_SLOT */
309+ #else /* ! __ARCH_WANT_KPROBES_INSN_SLOT */
307310#define DEFINE_INSN_CACHE_OPS (__name ) \
308311static inline bool is_kprobe_##__name##_slot(unsigned long addr) \
309312{ \
@@ -345,11 +348,12 @@ extern int sysctl_kprobes_optimization;
345348extern int proc_kprobes_optimization_handler (struct ctl_table * table ,
346349 int write , void * buffer ,
347350 size_t * length , loff_t * ppos );
348- #endif
351+ #endif /* CONFIG_SYSCTL */
349352extern void wait_for_kprobe_optimizer (void );
350- #else
353+ #else /* !CONFIG_OPTPROBES */
351354static inline void wait_for_kprobe_optimizer (void ) { }
352355#endif /* CONFIG_OPTPROBES */
356+
353357#ifdef CONFIG_KPROBES_ON_FTRACE
354358extern void kprobe_ftrace_handler (unsigned long ip , unsigned long parent_ip ,
355359 struct ftrace_ops * ops , struct ftrace_regs * fregs );
@@ -359,15 +363,15 @@ static inline int arch_prepare_kprobe_ftrace(struct kprobe *p)
359363{
360364 return - EINVAL ;
361365}
362- #endif
366+ #endif /* CONFIG_KPROBES_ON_FTRACE */
363367
364368/* Get the kprobe at this addr (if any) - called with preemption disabled */
365369struct kprobe * get_kprobe (void * addr );
366370
367371/* kprobe_running() will just return the current_kprobe on this CPU */
368372static inline struct kprobe * kprobe_running (void )
369373{
370- return ( __this_cpu_read (current_kprobe ) );
374+ return __this_cpu_read (current_kprobe );
371375}
372376
373377static inline void reset_current_kprobe (void )
@@ -431,11 +435,11 @@ static inline struct kprobe *kprobe_running(void)
431435}
432436static inline int register_kprobe (struct kprobe * p )
433437{
434- return - ENOSYS ;
438+ return - EOPNOTSUPP ;
435439}
436440static inline int register_kprobes (struct kprobe * * kps , int num )
437441{
438- return - ENOSYS ;
442+ return - EOPNOTSUPP ;
439443}
440444static inline void unregister_kprobe (struct kprobe * p )
441445{
@@ -445,11 +449,11 @@ static inline void unregister_kprobes(struct kprobe **kps, int num)
445449}
446450static inline int register_kretprobe (struct kretprobe * rp )
447451{
448- return - ENOSYS ;
452+ return - EOPNOTSUPP ;
449453}
450454static inline int register_kretprobes (struct kretprobe * * rps , int num )
451455{
452- return - ENOSYS ;
456+ return - EOPNOTSUPP ;
453457}
454458static inline void unregister_kretprobe (struct kretprobe * rp )
455459{
@@ -465,11 +469,11 @@ static inline void kprobe_free_init_mem(void)
465469}
466470static inline int disable_kprobe (struct kprobe * kp )
467471{
468- return - ENOSYS ;
472+ return - EOPNOTSUPP ;
469473}
470474static inline int enable_kprobe (struct kprobe * kp )
471475{
472- return - ENOSYS ;
476+ return - EOPNOTSUPP ;
473477}
474478
475479static inline bool within_kprobe_blacklist (unsigned long addr )
@@ -482,6 +486,7 @@ static inline int kprobe_get_kallsym(unsigned int symnum, unsigned long *value,
482486 return - ERANGE ;
483487}
484488#endif /* CONFIG_KPROBES */
489+
485490static inline int disable_kretprobe (struct kretprobe * rp )
486491{
487492 return disable_kprobe (& rp -> kp );
@@ -496,13 +501,14 @@ static inline bool is_kprobe_insn_slot(unsigned long addr)
496501{
497502 return false;
498503}
499- #endif
504+ #endif /* !CONFIG_KPROBES */
505+
500506#ifndef CONFIG_OPTPROBES
501507static inline bool is_kprobe_optinsn_slot (unsigned long addr )
502508{
503509 return false;
504510}
505- #endif
511+ #endif /* !CONFIG_OPTPROBES */
506512
507513/* Returns true if kprobes handled the fault */
508514static nokprobe_inline bool kprobe_page_fault (struct pt_regs * regs ,
0 commit comments