diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/kernel/kprobes.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 14 | ||||
-rw-r--r-- | arch/sparc64/kernel/kprobes.c | 6 | ||||
-rw-r--r-- | arch/x86_64/kernel/kprobes.c | 7 |
4 files changed, 10 insertions, 23 deletions
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c index 19edcd526ba4..68fe10250486 100644 --- a/arch/i386/kernel/kprobes.c +++ b/arch/i386/kernel/kprobes.c | |||
@@ -58,13 +58,9 @@ static inline int is_IF_modifier(kprobe_opcode_t opcode) | |||
58 | 58 | ||
59 | int __kprobes arch_prepare_kprobe(struct kprobe *p) | 59 | int __kprobes arch_prepare_kprobe(struct kprobe *p) |
60 | { | 60 | { |
61 | return 0; | ||
62 | } | ||
63 | |||
64 | void __kprobes arch_copy_kprobe(struct kprobe *p) | ||
65 | { | ||
66 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); | 61 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); |
67 | p->opcode = *p->addr; | 62 | p->opcode = *p->addr; |
63 | return 0; | ||
68 | } | 64 | } |
69 | 65 | ||
70 | void __kprobes arch_arm_kprobe(struct kprobe *p) | 66 | void __kprobes arch_arm_kprobe(struct kprobe *p) |
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 5368f9c2e6bf..331e169e8629 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -60,13 +60,13 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) | |||
60 | if (!p->ainsn.insn) | 60 | if (!p->ainsn.insn) |
61 | ret = -ENOMEM; | 61 | ret = -ENOMEM; |
62 | } | 62 | } |
63 | return ret; | ||
64 | } | ||
65 | 63 | ||
66 | void __kprobes arch_copy_kprobe(struct kprobe *p) | 64 | if (!ret) { |
67 | { | 65 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); |
68 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); | 66 | p->opcode = *p->addr; |
69 | p->opcode = *p->addr; | 67 | } |
68 | |||
69 | return ret; | ||
70 | } | 70 | } |
71 | 71 | ||
72 | void __kprobes arch_arm_kprobe(struct kprobe *p) | 72 | void __kprobes arch_arm_kprobe(struct kprobe *p) |
@@ -85,9 +85,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) | |||
85 | 85 | ||
86 | void __kprobes arch_remove_kprobe(struct kprobe *p) | 86 | void __kprobes arch_remove_kprobe(struct kprobe *p) |
87 | { | 87 | { |
88 | down(&kprobe_mutex); | ||
89 | free_insn_slot(p->ainsn.insn); | 88 | free_insn_slot(p->ainsn.insn); |
90 | up(&kprobe_mutex); | ||
91 | } | 89 | } |
92 | 90 | ||
93 | static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) | 91 | static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) |
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c index a97b0f0727ab..bbd5aa6818ea 100644 --- a/arch/sparc64/kernel/kprobes.c +++ b/arch/sparc64/kernel/kprobes.c | |||
@@ -43,14 +43,10 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); | |||
43 | 43 | ||
44 | int __kprobes arch_prepare_kprobe(struct kprobe *p) | 44 | int __kprobes arch_prepare_kprobe(struct kprobe *p) |
45 | { | 45 | { |
46 | return 0; | ||
47 | } | ||
48 | |||
49 | void __kprobes arch_copy_kprobe(struct kprobe *p) | ||
50 | { | ||
51 | p->ainsn.insn[0] = *p->addr; | 46 | p->ainsn.insn[0] = *p->addr; |
52 | p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2; | 47 | p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2; |
53 | p->opcode = *p->addr; | 48 | p->opcode = *p->addr; |
49 | return 0; | ||
54 | } | 50 | } |
55 | 51 | ||
56 | void __kprobes arch_arm_kprobe(struct kprobe *p) | 52 | void __kprobes arch_arm_kprobe(struct kprobe *p) |
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c index afe11f4fbd1d..8b8943bfb89e 100644 --- a/arch/x86_64/kernel/kprobes.c +++ b/arch/x86_64/kernel/kprobes.c | |||
@@ -42,8 +42,8 @@ | |||
42 | #include <asm/pgtable.h> | 42 | #include <asm/pgtable.h> |
43 | #include <asm/kdebug.h> | 43 | #include <asm/kdebug.h> |
44 | 44 | ||
45 | static DECLARE_MUTEX(kprobe_mutex); | ||
46 | void jprobe_return_end(void); | 45 | void jprobe_return_end(void); |
46 | void __kprobes arch_copy_kprobe(struct kprobe *p); | ||
47 | 47 | ||
48 | DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; | 48 | DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; |
49 | DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); | 49 | DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); |
@@ -69,12 +69,11 @@ static inline int is_IF_modifier(kprobe_opcode_t *insn) | |||
69 | int __kprobes arch_prepare_kprobe(struct kprobe *p) | 69 | int __kprobes arch_prepare_kprobe(struct kprobe *p) |
70 | { | 70 | { |
71 | /* insn: must be on special executable page on x86_64. */ | 71 | /* insn: must be on special executable page on x86_64. */ |
72 | down(&kprobe_mutex); | ||
73 | p->ainsn.insn = get_insn_slot(); | 72 | p->ainsn.insn = get_insn_slot(); |
74 | up(&kprobe_mutex); | ||
75 | if (!p->ainsn.insn) { | 73 | if (!p->ainsn.insn) { |
76 | return -ENOMEM; | 74 | return -ENOMEM; |
77 | } | 75 | } |
76 | arch_copy_kprobe(p); | ||
78 | return 0; | 77 | return 0; |
79 | } | 78 | } |
80 | 79 | ||
@@ -223,9 +222,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) | |||
223 | 222 | ||
224 | void __kprobes arch_remove_kprobe(struct kprobe *p) | 223 | void __kprobes arch_remove_kprobe(struct kprobe *p) |
225 | { | 224 | { |
226 | down(&kprobe_mutex); | ||
227 | free_insn_slot(p->ainsn.insn); | 225 | free_insn_slot(p->ainsn.insn); |
228 | up(&kprobe_mutex); | ||
229 | } | 226 | } |
230 | 227 | ||
231 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) | 228 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) |