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/sparc64/kernel | |
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/sparc64/kernel')
-rw-r--r-- | arch/sparc64/kernel/kprobes.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c index ff5e9d5cad50..b9a9ce70e55c 100644 --- a/arch/sparc64/kernel/kprobes.c +++ b/arch/sparc64/kernel/kprobes.c | |||
@@ -135,6 +135,14 @@ static int __kprobes kprobe_handler(struct pt_regs *regs) | |||
135 | prepare_singlestep(p, regs, kcb); | 135 | prepare_singlestep(p, regs, kcb); |
136 | return 1; | 136 | return 1; |
137 | } else { | 137 | } else { |
138 | if (*(u32 *)addr != BREAKPOINT_INSTRUCTION) { | ||
139 | /* The breakpoint instruction was removed by | ||
140 | * another cpu right after we hit, no further | ||
141 | * handling of this interrupt is appropriate | ||
142 | */ | ||
143 | ret = 1; | ||
144 | goto no_kprobe; | ||
145 | } | ||
138 | p = __get_cpu_var(current_kprobe); | 146 | p = __get_cpu_var(current_kprobe); |
139 | if (p->break_handler && p->break_handler(p, regs)) | 147 | if (p->break_handler && p->break_handler(p, regs)) |
140 | goto ss_probe; | 148 | goto ss_probe; |