diff options
| author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-04-17 04:18:14 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-04-24 04:26:38 -0400 |
| commit | 9326638cbee2d36b051ed2a69f3e4e107e5f86bd (patch) | |
| tree | 995433e24b135a2858765519aec8fe9e889afd68 | |
| parent | 9c54b6164eeb292a0eac86c6913bd8daaff35e62 (diff) | |
kprobes, x86: Use NOKPROBE_SYMBOL() instead of __kprobes annotation
Use NOKPROBE_SYMBOL macro for protecting functions
from kprobes instead of __kprobes annotation under
arch/x86.
This applies nokprobe_inline annotation for some cases,
because NOKPROBE_SYMBOL() will inhibit inlining by
referring the symbol address.
This just folds a bunch of previous NOKPROBE_SYMBOL()
cleanup patches for x86 to one patch.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Link: http://lkml.kernel.org/r/20140417081814.26341.51656.stgit@ltc230.yrl.intra.hitachi.co.jp
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fernando Luis Vázquez Cao <fernando_b1@lab.ntt.co.jp>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Lebon <jlebon@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | arch/x86/include/asm/traps.h | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/apic/hw_nmi.c | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/perf_event.c | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/perf_event_amd_ibs.c | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/dumpstack.c | 9 | ||||
| -rw-r--r-- | arch/x86/kernel/kprobes/core.c | 77 | ||||
| -rw-r--r-- | arch/x86/kernel/kprobes/ftrace.c | 15 | ||||
| -rw-r--r-- | arch/x86/kernel/kprobes/opt.c | 8 | ||||
| -rw-r--r-- | arch/x86/kernel/kvm.c | 4 | ||||
| -rw-r--r-- | arch/x86/kernel/nmi.c | 18 | ||||
| -rw-r--r-- | arch/x86/kernel/traps.c | 20 | ||||
| -rw-r--r-- | arch/x86/mm/fault.c | 29 |
12 files changed, 122 insertions, 69 deletions
diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index 58d66fe06b61..ca32508c58c5 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h | |||
| @@ -68,7 +68,7 @@ dotraplinkage void do_segment_not_present(struct pt_regs *, long); | |||
| 68 | dotraplinkage void do_stack_segment(struct pt_regs *, long); | 68 | dotraplinkage void do_stack_segment(struct pt_regs *, long); |
| 69 | #ifdef CONFIG_X86_64 | 69 | #ifdef CONFIG_X86_64 |
| 70 | dotraplinkage void do_double_fault(struct pt_regs *, long); | 70 | dotraplinkage void do_double_fault(struct pt_regs *, long); |
| 71 | asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *); | 71 | asmlinkage struct pt_regs *sync_regs(struct pt_regs *); |
| 72 | #endif | 72 | #endif |
| 73 | dotraplinkage void do_general_protection(struct pt_regs *, long); | 73 | dotraplinkage void do_general_protection(struct pt_regs *, long); |
| 74 | dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); | 74 | dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); |
diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c index a698d7165c96..73eb5b336f63 100644 --- a/arch/x86/kernel/apic/hw_nmi.c +++ b/arch/x86/kernel/apic/hw_nmi.c | |||
| @@ -60,7 +60,7 @@ void arch_trigger_all_cpu_backtrace(void) | |||
| 60 | smp_mb__after_clear_bit(); | 60 | smp_mb__after_clear_bit(); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | static int __kprobes | 63 | static int |
| 64 | arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) | 64 | arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) |
| 65 | { | 65 | { |
| 66 | int cpu; | 66 | int cpu; |
| @@ -80,6 +80,7 @@ arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) | |||
| 80 | 80 | ||
| 81 | return NMI_DONE; | 81 | return NMI_DONE; |
| 82 | } | 82 | } |
| 83 | NOKPROBE_SYMBOL(arch_trigger_all_cpu_backtrace_handler); | ||
| 83 | 84 | ||
| 84 | static int __init register_trigger_all_cpu_backtrace(void) | 85 | static int __init register_trigger_all_cpu_backtrace(void) |
| 85 | { | 86 | { |
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index ae407f7226c8..5fc8771979ba 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c | |||
| @@ -1292,7 +1292,7 @@ void perf_events_lapic_init(void) | |||
| 1292 | apic_write(APIC_LVTPC, APIC_DM_NMI); | 1292 | apic_write(APIC_LVTPC, APIC_DM_NMI); |
| 1293 | } | 1293 | } |
| 1294 | 1294 | ||
| 1295 | static int __kprobes | 1295 | static int |
| 1296 | perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs) | 1296 | perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs) |
| 1297 | { | 1297 | { |
| 1298 | u64 start_clock; | 1298 | u64 start_clock; |
| @@ -1310,6 +1310,7 @@ perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs) | |||
| 1310 | 1310 | ||
| 1311 | return ret; | 1311 | return ret; |
| 1312 | } | 1312 | } |
| 1313 | NOKPROBE_SYMBOL(perf_event_nmi_handler); | ||
| 1313 | 1314 | ||
| 1314 | struct event_constraint emptyconstraint; | 1315 | struct event_constraint emptyconstraint; |
| 1315 | struct event_constraint unconstrained; | 1316 | struct event_constraint unconstrained; |
diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c index 4c36bbe3173a..cbb1be3ed9e4 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c +++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c | |||
| @@ -593,7 +593,7 @@ out: | |||
| 593 | return 1; | 593 | return 1; |
| 594 | } | 594 | } |
| 595 | 595 | ||
| 596 | static int __kprobes | 596 | static int |
| 597 | perf_ibs_nmi_handler(unsigned int cmd, struct pt_regs *regs) | 597 | perf_ibs_nmi_handler(unsigned int cmd, struct pt_regs *regs) |
| 598 | { | 598 | { |
| 599 | int handled = 0; | 599 | int handled = 0; |
| @@ -606,6 +606,7 @@ perf_ibs_nmi_handler(unsigned int cmd, struct pt_regs *regs) | |||
| 606 | 606 | ||
| 607 | return handled; | 607 | return handled; |
| 608 | } | 608 | } |
| 609 | NOKPROBE_SYMBOL(perf_ibs_nmi_handler); | ||
| 609 | 610 | ||
| 610 | static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) | 611 | static __init int perf_ibs_pmu_init(struct perf_ibs *perf_ibs, char *name) |
| 611 | { | 612 | { |
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index d9c12d3022a7..b74ebc7c4402 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c | |||
| @@ -200,7 +200,7 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED; | |||
| 200 | static int die_owner = -1; | 200 | static int die_owner = -1; |
| 201 | static unsigned int die_nest_count; | 201 | static unsigned int die_nest_count; |
| 202 | 202 | ||
| 203 | unsigned __kprobes long oops_begin(void) | 203 | unsigned long oops_begin(void) |
| 204 | { | 204 | { |
| 205 | int cpu; | 205 | int cpu; |
| 206 | unsigned long flags; | 206 | unsigned long flags; |
| @@ -223,8 +223,9 @@ unsigned __kprobes long oops_begin(void) | |||
| 223 | return flags; | 223 | return flags; |
| 224 | } | 224 | } |
| 225 | EXPORT_SYMBOL_GPL(oops_begin); | 225 | EXPORT_SYMBOL_GPL(oops_begin); |
| 226 | NOKPROBE_SYMBOL(oops_begin); | ||
| 226 | 227 | ||
| 227 | void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr) | 228 | void oops_end(unsigned long flags, struct pt_regs *regs, int signr) |
| 228 | { | 229 | { |
| 229 | if (regs && kexec_should_crash(current)) | 230 | if (regs && kexec_should_crash(current)) |
| 230 | crash_kexec(regs); | 231 | crash_kexec(regs); |
| @@ -247,8 +248,9 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr) | |||
| 247 | panic("Fatal exception"); | 248 | panic("Fatal exception"); |
| 248 | do_exit(signr); | 249 | do_exit(signr); |
| 249 | } | 250 | } |
| 251 | NOKPROBE_SYMBOL(oops_end); | ||
| 250 | 252 | ||
| 251 | int __kprobes __die(const char *str, struct pt_regs *regs, long err) | 253 | int __die(const char *str, struct pt_regs *regs, long err) |
| 252 | { | 254 | { |
| 253 | #ifdef CONFIG_X86_32 | 255 | #ifdef CONFIG_X86_32 |
| 254 | unsigned short ss; | 256 | unsigned short ss; |
| @@ -291,6 +293,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err) | |||
| 291 | #endif | 293 | #endif |
| 292 | return 0; | 294 | return 0; |
| 293 | } | 295 | } |
| 296 | NOKPROBE_SYMBOL(__die); | ||
| 294 | 297 | ||
| 295 | /* | 298 | /* |
| 296 | * This is gone through when something in the kernel has done something bad | 299 | * This is gone through when something in the kernel has done something bad |
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index bd717137ae77..7596df664901 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
| @@ -112,7 +112,8 @@ struct kretprobe_blackpoint kretprobe_blacklist[] = { | |||
| 112 | 112 | ||
| 113 | const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist); | 113 | const int kretprobe_blacklist_size = ARRAY_SIZE(kretprobe_blacklist); |
| 114 | 114 | ||
| 115 | static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op) | 115 | static nokprobe_inline void |
| 116 | __synthesize_relative_insn(void *from, void *to, u8 op) | ||
| 116 | { | 117 | { |
| 117 | struct __arch_relative_insn { | 118 | struct __arch_relative_insn { |
| 118 | u8 op; | 119 | u8 op; |
| @@ -125,21 +126,23 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op) | |||
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/ | 128 | /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/ |
| 128 | void __kprobes synthesize_reljump(void *from, void *to) | 129 | void synthesize_reljump(void *from, void *to) |
| 129 | { | 130 | { |
| 130 | __synthesize_relative_insn(from, to, RELATIVEJUMP_OPCODE); | 131 | __synthesize_relative_insn(from, to, RELATIVEJUMP_OPCODE); |
| 131 | } | 132 | } |
| 133 | NOKPROBE_SYMBOL(synthesize_reljump); | ||
| 132 | 134 | ||
| 133 | /* Insert a call instruction at address 'from', which calls address 'to'.*/ | 135 | /* Insert a call instruction at address 'from', which calls address 'to'.*/ |
| 134 | void __kprobes synthesize_relcall(void *from, void *to) | 136 | void synthesize_relcall(void *from, void *to) |
| 135 | { | 137 | { |
| 136 | __synthesize_relative_insn(from, to, RELATIVECALL_OPCODE); | 138 | __synthesize_relative_insn(from, to, RELATIVECALL_OPCODE); |
| 137 | } | ||
