diff options
author | Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> | 2006-01-11 15:17:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-11 21:42:12 -0500 |
commit | eb3a72921c8276bf2cd028a458bb83435f16c91c (patch) | |
tree | 634eff43e1926bdb400d038eb08115193b6a7506 /arch/powerpc | |
parent | df019b1d8b893d0f0ee5a9b0f71486f0892561ae (diff) |
[PATCH] kprobes: fix race in recovery of reentrant probe
There is a window where a probe gets removed right after the probe is hit
on some different cpu. In this case probe handlers can't find a matching
probe instance related to break address. In this case we need to read the
original instruction at break address to see if that is not a break/int3
instruction and recover safely.
Previous code had a bug where we were not checking for the above race in
case of reentrant probes and the below patch fixes this race.
Tested on IA64, Powerpc, x86_64.
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 27b0c40601fb..cfab48566db1 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -179,6 +179,18 @@ static inline int kprobe_handler(struct pt_regs *regs) | |||
179 | kcb->kprobe_status = KPROBE_REENTER; | 179 | kcb->kprobe_status = KPROBE_REENTER; |
180 | return 1; | 180 | return 1; |
181 | } else { | 181 | } else { |
182 | if (*addr != BREAKPOINT_INSTRUCTION) { | ||
183 | /* If trap variant, then it belongs not to us */ | ||
184 | kprobe_opcode_t cur_insn = *addr; | ||
185 | if (is_trap(cur_insn)) | ||
186 | goto no_kprobe; | ||
187 | /* The breakpoint instruction was removed by | ||
188 | * another cpu right after we hit, no further | ||
189 | * handling of this interrupt is appropriate | ||
190 | */ | ||
191 | ret = 1; | ||
192 | goto no_kprobe; | ||
193 | } | ||
182 | p = __get_cpu_var(current_kprobe); | 194 | p = __get_cpu_var(current_kprobe); |
183 | if (p->break_handler && p->break_handler(p, regs)) { | 195 | if (p->break_handler && p->break_handler(p, regs)) { |
184 | goto ss_probe; | 196 | goto ss_probe; |