diff options
author | Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> | 2005-09-06 18:19:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:58:01 -0400 |
commit | deac66ae454cacf942c051b86d9232af546fb187 (patch) | |
tree | 17a72e7a2dcf2d1a93a6afdef661f290b1888f1c /arch/ppc64/kernel/kprobes.c | |
parent | bce0649417d6e71f6df8ab7b11103d247913b142 (diff) |
[PATCH] kprobes: fix bug when probed on task and isr functions
This patch fixes a race condition where in system used to hang or sometime
crash within minutes when kprobes are inserted on ISR routine and a task
routine.
The fix has been stress tested on i386, ia64, pp64 and on x86_64. To
reproduce the problem insert kprobes on schedule() and do_IRQ() functions
and you should see hang or system crash.
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ppc64/kernel/kprobes.c')
-rw-r--r-- | arch/ppc64/kernel/kprobes.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/ppc64/kernel/kprobes.c b/arch/ppc64/kernel/kprobes.c index 591e4b67b5a5..7e80d49c589a 100644 --- a/arch/ppc64/kernel/kprobes.c +++ b/arch/ppc64/kernel/kprobes.c | |||
@@ -102,7 +102,7 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) | |||
102 | regs->msr |= MSR_SE; | 102 | regs->msr |= MSR_SE; |
103 | 103 | ||
104 | /* single step inline if it is a trap variant */ | 104 | /* single step inline if it is a trap variant */ |
105 | if (IS_TW(insn) || IS_TD(insn) || IS_TWI(insn) || IS_TDI(insn)) | 105 | if (is_trap(insn)) |
106 | regs->nip = (unsigned long)p->addr; | 106 | regs->nip = (unsigned long)p->addr; |
107 | else | 107 | else |
108 | regs->nip = (unsigned long)p->ainsn.insn; | 108 | regs->nip = (unsigned long)p->ainsn.insn; |
@@ -152,7 +152,9 @@ static inline int kprobe_handler(struct pt_regs *regs) | |||
152 | Disarm the probe we just hit, and ignore it. */ | 152 | Disarm the probe we just hit, and ignore it. */ |
153 | p = get_kprobe(addr); | 153 | p = get_kprobe(addr); |
154 | if (p) { | 154 | if (p) { |
155 | if (kprobe_status == KPROBE_HIT_SS) { | 155 | kprobe_opcode_t insn = *p->ainsn.insn; |
156 | if (kprobe_status == KPROBE_HIT_SS && | ||
157 | is_trap(insn)) { | ||
156 | regs->msr &= ~MSR_SE; | 158 | regs->msr &= ~MSR_SE; |
157 | regs->msr |= kprobe_saved_msr; | 159 | regs->msr |= kprobe_saved_msr; |
158 | unlock_kprobes(); | 160 | unlock_kprobes(); |
@@ -192,8 +194,7 @@ static inline int kprobe_handler(struct pt_regs *regs) | |||
192 | * trap variant, it could belong to someone else | 194 | * trap variant, it could belong to someone else |
193 | */ | 195 | */ |
194 | kprobe_opcode_t cur_insn = *addr; | 196 | kprobe_opcode_t cur_insn = *addr; |
195 | if (IS_TW(cur_insn) || IS_TD(cur_insn) || | 197 | if (is_trap(cur_insn)) |
196 | IS_TWI(cur_insn) || IS_TDI(cur_insn)) | ||
197 | goto no_kprobe; | 198 | goto no_kprobe; |
198 | /* | 199 | /* |
199 | * The breakpoint instruction was removed right | 200 | * The breakpoint instruction was removed right |
@@ -403,7 +404,7 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self, | |||
403 | default: | 404 | default: |
404 | break; | 405 | break; |
405 | } | 406 | } |
406 | preempt_enable(); | 407 | preempt_enable_no_resched(); |
407 | return ret; | 408 | return ret; |
408 | } | 409 | } |
409 | 410 | ||