public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Fix int1 recursion when no perf_bp_event is registered
@ 2015-12-10  7:12 Jeff Merkey
  2015-12-10 18:55 ` Thomas Gleixner
  0 siblings, 1 reply; 23+ messages in thread
From: Jeff Merkey @ 2015-12-10  7:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, mingo, hpa, x86

If an int1 hardware breakpoint exception is triggered, but no perf bp
pevent block was registered from arch_install_hw_breakpoint, the
system will hard hang with the CPU stuck constantly re-interrupting at
the same execution address because the resume flag never gets set, and
the NOTIFY_DONE state prevents other int1 handlers, including the
default handler in do_debug, from running to handle the condition.
Can be reproduced by writing a program that sets an execute breakpoint
at schedule() without calling arch_install_hw_breakpoint.

The proposed fix checks the dr7 register and sets the resume flag in
pt->regs if it determines an executed breakpoint was triggered just in
case the check lower down fails.  I have seen this bug and its a bug.

Signed-off-by:  jeffmerkey@gmail.com
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index 50a3fad..6effcae 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -475,6 +475,14 @@ static int hw_breakpoint_handler(struct die_args *args)
 	for (i = 0; i < HBP_NUM; ++i) {
 		if (likely(!(dr6 & (DR_TRAP0 << i))))
 			continue;
+		/*
+		 * Set up resume flag to avoid breakpoint recursion when
+		 * returning back to origin in the event an int1
+		 * exception is triggered and no event handler
+		 * is present.
+		 */
+		if ((dr7 & (3 << ((i * 4) + 16))) == 0)
+			args->regs->flags |= X86_EFLAGS_RF;

 		/*
 		 * The counter may be concurrently released but that can only

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2015-12-14 18:18 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-10  7:12 [PATCH 1/1] Fix int1 recursion when no perf_bp_event is registered Jeff Merkey
2015-12-10 18:55 ` Thomas Gleixner
2015-12-10 19:09   ` Andy Lutomirski
2015-12-10 19:20     ` Jiri Olsa
2015-12-10 19:25       ` Borislav Petkov
2015-12-10 20:49     ` [PATCH 1/1] Fix int1 recursion when no perf_bp_event is registeredy Thomas Gleixner
2015-12-10 21:09       ` Andy Lutomirski
2015-12-10 21:15         ` Thomas Gleixner
2015-12-10 21:26           ` Jeff Merkey
2015-12-10 21:16         ` Jeff Merkey
2015-12-14  8:09           ` Ingo Molnar
2015-12-14  8:13             ` Jeff Merkey
2015-12-14  8:26               ` Jeff Merkey
2015-12-14  9:28               ` Ingo Molnar
2015-12-14 17:52                 ` Jeff Merkey
2015-12-14 17:56                   ` Andy Lutomirski
2015-12-14 18:16                     ` Jeff Merkey
2015-12-14 18:18                     ` Jeff Merkey
2015-12-10 21:11       ` Jeff Merkey
2015-12-10 22:26       ` Jeff Merkey
2015-12-11  8:05       ` [PATCH v2 " Jeff Merkey
2015-12-11 19:04         ` Jeff Merkey
2015-12-13 23:11         ` Jeff Merkey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox