Skip to content

Commit a195f3d

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/debug: Only clear/set ->virtual_dr6 for userspace #DB
The ->virtual_dr6 is the value used by ptrace_{get,set}_debugreg(6). A kernel #DB clearing it could mean spurious malfunction of ptrace() expectations. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Kyle Huey <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2a9baf5 commit a195f3d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/x86/kernel/traps.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,6 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
793793
set_debugreg(DR6_RESERVED, 6);
794794
dr6 ^= DR6_RESERVED; /* Flip to positive polarity */
795795

796-
/*
797-
* Clear the virtual DR6 value, ptrace routines will set bits here for
798-
* things we want signals for.
799-
*/
800-
current->thread.virtual_dr6 = 0;
801-
802796
return dr6;
803797
}
804798

@@ -942,6 +936,12 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
942936
irqentry_enter_from_user_mode(regs);
943937
instrumentation_begin();
944938

939+
/*
940+
* Clear the virtual DR6 value, ptrace() routines will set bits here
941+
* for things it wants signals for.
942+
*/
943+
current->thread.virtual_dr6 = 0;
944+
945945
/*
946946
* The SDM says "The processor clears the BTF flag when it
947947
* generates a debug exception." Clear TIF_BLOCKSTEP to keep

0 commit comments

Comments
 (0)