diff options
author | 2006-01-11 12:17:42 -0800 | |
---|---|---|
committer | 2006-01-11 18:42:12 -0800 | |
commit | eb3a72921c8276bf2cd028a458bb83435f16c91c (patch) | |
tree | 634eff43e1926bdb400d038eb08115193b6a7506 /arch/i386 | |
parent | [PATCH] kprobes: fix unloading of self probed module (diff) | |
download | linux-eb3a72921c8276bf2cd028a458bb83435f16c91c.tar.gz linux-eb3a72921c8276bf2cd028a458bb83435f16c91c.tar.bz2 linux-eb3a72921c8276bf2cd028a458bb83435f16c91c.zip |
[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/i386')
-rw-r--r-- | arch/i386/kernel/kprobes.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c index 2f372dbd34fd..6483eeb1a4e8 100644 --- a/arch/i386/kernel/kprobes.c +++ b/arch/i386/kernel/kprobes.c @@ -188,6 +188,19 @@ static int __kprobes kprobe_handler(struct pt_regs *regs) kcb->kprobe_status = KPROBE_REENTER; return 1; } else { + if (regs->eflags & VM_MASK) { + /* We are in virtual-8086 mode. Return 0 */ + goto no_kprobe; + } + if (*addr != BREAKPOINT_INSTRUCTION) { + /* The breakpoint instruction was removed by + * another cpu right after we hit, no further + * handling of this interrupt is appropriate + */ + regs->eip -= sizeof(kprobe_opcode_t); + ret = 1; + goto no_kprobe; + } p = __get_cpu_var(current_kprobe); if (p->break_handler && p->break_handler(p, regs)) { goto ss_probe; |