Currently, the breakpoint exception handler executes STI, which enables interrupts even when the breakpoint is located in an interrupt-disabled critical section. Such situations usually correlate with kprobes, where breakpoints are used to trap into the handlers and single-step the original instruction. As a result, registering kprobes into an IRQ-disabled critical section could accidentally enable interrupts. Though returning to the next instruction will restore (i.e., disable) interrupts again, it may have caused irreversible consequences during breakpoint handling. Build the breakpoint handler with KMODE to enter kernel mode with interrupts left as they are. Fixes: c1bf207d6ee1 ("MIPS: kprobe: Add support.") Cc: stable@vger.kernel.org Co-developed-by: Mike Yang Signed-off-by: Mike Yang Signed-off-by: Rong Zhang --- arch/mips/kernel/genex.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S index be1b049d856f..e7a5f6bc31ff 100644 --- a/arch/mips/kernel/genex.S +++ b/arch/mips/kernel/genex.S @@ -485,6 +485,10 @@ NESTED(nmi_handler, PT_SIZE, sp) TRACE_IRQS_OFF .endm + .macro __build_clear_kmode + KMODE + .endm + .macro __build_clear_fpe CLI TRACE_IRQS_OFF @@ -569,7 +573,7 @@ NESTED(nmi_handler, PT_SIZE, sp) BUILD_HANDLER ades ade ade silent /* #5 */ BUILD_HANDLER ibe be cli silent /* #6 */ BUILD_HANDLER dbe be cli silent /* #7 */ - BUILD_HANDLER bp bp sti silent /* #9 */ + BUILD_HANDLER bp bp kmode silent /* #9 */ BUILD_HANDLER ri ri sti silent /* #10 */ BUILD_HANDLER cpu cpu sti silent /* #11 */ BUILD_HANDLER ov ov sti silent /* #12 */ -- 2.55.0