diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-06-30 09:09:06 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-06-30 10:16:20 -0400 |
commit | a1e80fafc9f0742a1776a0490258cb64912411b0 (patch) | |
tree | bedbb0182393c77051b2d7e2e492f443e5fca9a4 /arch | |
parent | b70e4f0529c089b00d0a6da13106db4de1ada4c7 (diff) |
x86: Send a SIGTRAP for user icebp traps
Before we had a generic breakpoint layer, x86 used to send a
sigtrap for any debug event that happened in userspace,
except if it was caused by lazy dr7 switches.
Currently we only send such signal for single step or breakpoint
events.
However, there are three other kind of debug exceptions:
- debug register access detected: trigger an exception if the
next instruction touches the debug registers. We don't use
it.
- task switch, but we don't use tss.
- icebp/int01 trap. This instruction (0xf1) is undocumented and
generates an int 1 exception. Unlike single step through TF
flag, it doesn't set the single step origin of the exception
in dr6.
icebp then used to be reported in userspace using trap signals
but this have been incidentally broken with the new breakpoint
code. Reenable this. Since this is the only debug event that
doesn't set anything in dr6, this is all we have to check.
This fixes a regression in Wine where World Of Warcraft got broken
as it uses this for software protection checks purposes. And
probably other apps do.
Reported-and-tested-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: 2.6.33.x 2.6.34.x <stable@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/traps.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 142d70c74b02..725ef4d17cd5 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -526,6 +526,7 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs) | |||
526 | dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code) | 526 | dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code) |
527 | { | 527 | { |
528 | struct task_struct *tsk = current; | 528 | struct task_struct *tsk = current; |
529 | int user_icebp = 0; | ||
529 | unsigned long dr6; | 530 | unsigned long dr6; |
530 | int si_code; | 531 | int si_code; |
531 | 532 | ||
@@ -534,6 +535,14 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code) | |||
534 | /* Filter out all the reserved bits which are preset to 1 */ | 535 | /* Filter out all the reserved bits which are preset to 1 */ |
535 | dr6 &= ~DR6_RESERVED; | 536 | dr6 &= ~DR6_RESERVED; |
536 | 537 | ||
538 | /* | ||
539 | * If dr6 has no reason to give us about the origin of this trap, | ||
540 | * then it's very likely the result of an icebp/int01 trap. | ||
541 | * User wants a sigtrap for that. | ||
542 | */ | ||
543 | if (!dr6 && user_mode(regs)) | ||
544 | user_icebp = 1; | ||
545 | |||
537 | /* Catch kmemcheck conditions first of all! */ | 546 | /* Catch kmemcheck conditions first of all! */ |
538 | if ((dr6 & DR_STEP) && kmemcheck_trap(regs)) | 547 | if ((dr6 & DR_STEP) && kmemcheck_trap(regs)) |
539 | return; | 548 | return; |
@@ -575,7 +584,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code) | |||
575 | regs->flags &= ~X86_EFLAGS_TF; | 584 | regs->flags &= ~X86_EFLAGS_TF; |
576 | } | 585 | } |
577 | si_code = get_si_code(tsk->thread.debugreg6); | 586 | si_code = get_si_code(tsk->thread.debugreg6); |
578 | if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS)) | 587 | if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS) || user_icebp) |
579 | send_sigtrap(tsk, regs, error_code, si_code); | 588 | send_sigtrap(tsk, regs, error_code, si_code); |
580 | preempt_conditional_cli(regs); | 589 | preempt_conditional_cli(regs); |
581 | 590 | ||