lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sat, 12 Dec 2015 15:44:59 -0700
From:	Jeff Merkey <>
To:	LKML <>
Cc:	Thomas Gleixner <>,
	Andy Lutomirski <>,
	Ingo Molnar <>,
	"H. Peter Anvin" <>, X86 ML <>,
	Peter Zijlstra <>,
	Andy Lutomirski <>,
	Masami Hiramatsu <>,
	Steven Rostedt <>,
	Borislav Petkov <>, Jiri Olsa <>
Subject: [PATCH 1/1] Add hw_breakpoint_enable function

The current function to manually restore breakpoints
(hw_breakpoint_restore) places the contents of the thread.debugreg6
variable back into the dr6 hardware register, a piece of hardware
intended to be read, not used as local storage.  The problem with this
is that systems that register for breakpoints, including the perf
event system and kgdb/kdb, modify this variable.  I have observed
garbage stacked debug statuses being cycled through dr6 and this
variable over and over again in a loop by calls to
hw_breakpoint_restore() that cause strange behaviors in kdb and this
layer.  In short, I don't use this broken function.

This function is necessary because upon debugger entry, you must set
dr7 to 0 to disable breakpoints while inside the debugger then call
hw_breakpoint_restore() to reload the state and re-enable them.  This
function is identical to hw_breakpoint_restore() except it leaves out
writing a user defined thread.debugreg6 variable back into a hardware
register not intended for that purpose.

Signed-off-by:  Jeff V. Merkey  <>
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index 50a3fad..7ea0f78 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -425,6 +425,16 @@ void hw_breakpoint_restore(void)

+void hw_breakpoint_enable(void)
+	set_debugreg(__this_cpu_read(cpu_debugreg[0]), 0);
+	set_debugreg(__this_cpu_read(cpu_debugreg[1]), 1);
+	set_debugreg(__this_cpu_read(cpu_debugreg[2]), 2);
+	set_debugreg(__this_cpu_read(cpu_debugreg[3]), 3);
+	set_debugreg(__this_cpu_read(cpu_dr7), 7);
  * Handle debug exception notifications.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists