diff options
| author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-04-17 04:17:05 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-04-24 04:02:56 -0400 |
| commit | 376e242429bf8539ef39a080ac113c8799840b13 (patch) | |
| tree | 33c871f48d37acd167de0b3bf5c902ce4aaa325c /include/linux | |
| parent | be8f274323c26ddc7e6fd6c44254b7abcdbe6389 (diff) | |
kprobes: Introduce NOKPROBE_SYMBOL() macro to maintain kprobes blacklist
Introduce NOKPROBE_SYMBOL() macro which builds a kprobes
blacklist at kernel build time.
The usage of this macro is similar to EXPORT_SYMBOL(),
placed after the function definition:
NOKPROBE_SYMBOL(function);
Since this macro will inhibit inlining of static/inline
functions, this patch also introduces a nokprobe_inline macro
for static/inline functions. In this case, we must use
NOKPROBE_SYMBOL() for the inline function caller.
When CONFIG_KPROBES=y, the macro stores the given function
address in the "_kprobe_blacklist" section.
Since the data structures are not fully initialized by the
macro (because there is no "size" information), those
are re-initialized at boot time by using kallsyms.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Link: http://lkml.kernel.org/r/20140417081705.26341.96719.stgit@ltc230.yrl.intra.hitachi.co.jp
Cc: Alok Kataria <akataria@vmware.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Jan-Simon Möller <dl9pf@gmx.de>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-sparse@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/compiler.h | 2 | ||||
| -rw-r--r-- | include/linux/kprobes.h | 20 |
2 files changed, 19 insertions, 3 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index ee7239ea1583..0300c0f5c88b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
| @@ -374,7 +374,9 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); | |||
| 374 | /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */ | 374 | /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */ |
| 375 | #ifdef CONFIG_KPROBES | 375 | #ifdef CONFIG_KPROBES |
| 376 | # define __kprobes __attribute__((__section__(".kprobes.text"))) | 376 | # define __kprobes __attribute__((__section__(".kprobes.text"))) |
| 377 | # define nokprobe_inline __always_inline | ||
| 377 | #else | 378 | #else |
| 378 | # define __kprobes | 379 | # define __kprobes |
| 380 | # define nokprobe_inline inline | ||
| 379 | #endif | 381 | #endif |
| 380 | #endif /* __LINUX_COMPILER_H */ | 382 | #endif /* __LINUX_COMPILER_H */ |
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index cdf9251f8249..e059507c465d 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
| @@ -205,10 +205,10 @@ struct kretprobe_blackpoint { | |||
| 205 | void *addr; | 205 | void *addr; |
| 206 | }; | 206 | }; |
| 207 | 207 | ||
| 208 | struct kprobe_blackpoint { | 208 | struct kprobe_blacklist_entry { |
| 209 | const char *name; | 209 | struct list_head list; |
| 210 | unsigned long start_addr; | 210 | unsigned long start_addr; |
| 211 | unsigned long range; | 211 | unsigned long end_addr; |
| 212 | }; | 212 | }; |
| 213 | 213 | ||
| 214 | #ifdef CONFIG_KPROBES | 214 | #ifdef CONFIG_KPROBES |
| @@ -477,4 +477,18 @@ static inline int enable_jprobe(struct jprobe *jp) | |||
| 477 | return enable_kprobe(&jp->kp); | 477 | return enable_kprobe(&jp->kp); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | #ifdef CONFIG_KPROBES | ||
| 481 | /* | ||
| 482 | * Blacklist ganerating macro. Specify functions which is not probed | ||
| 483 | * by using this macro. | ||
| 484 | */ | ||
| 485 | #define __NOKPROBE_SYMBOL(fname) \ | ||
| 486 | static unsigned long __used \ | ||
| 487 | __attribute__((section("_kprobe_blacklist"))) \ | ||
| 488 | _kbl_addr_##fname = (unsigned long)fname; | ||
| 489 | #define NOKPROBE_SYMBOL(fname) __NOKPROBE_SYMBOL(fname) | ||
| 490 | #else | ||
| 491 | #define NOKPROBE_SYMBOL(fname) | ||
| 492 | #endif | ||
| 493 | |||
| 480 | #endif /* _LINUX_KPROBES_H */ | 494 | #endif /* _LINUX_KPROBES_H */ |
