Skip to content

Commit ea0d55a

Browse files
Ada Couprie Diazctmarinas
authored andcommitted
arm64: debug: always unmask interrupts in el0_softstp()
We intend that EL0 exception handlers unmask all DAIF exceptions before calling exit_to_user_mode(). When completing single-step of a suspended breakpoint, we do not call local_daif_restore(DAIF_PROCCTX) before calling exit_to_user_mode(), leaving all DAIF exceptions masked. When pseudo-NMIs are not in use this is benign. When pseudo-NMIs are in use, this is unsound. At this point interrupts are masked by both DAIF.IF and PMR_EL1, and subsequent irq flag manipulation may not work correctly. For example, a subsequent local_irq_enable() within exit_to_user_mode_loop() will only unmask interrupts via PMR_EL1 (leaving those masked via DAIF.IF), and anything depending on interrupts being unmasked (e.g. delivery of signals) will not work correctly. This was detected by CONFIG_ARM64_DEBUG_PRIORITY_MASKING. Move the call to `try_step_suspended_breakpoints()` outside of the check so that interrupts can be unmasked even if we don't call the step handler. Fixes: 0ac7584 ("arm64: debug: split single stepping exception entry") Cc: <stable@vger.kernel.org> # 6.17 Signed-off-by: Ada Couprie Diaz <ada.coupriediaz@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> [catalin.marinas@arm.com: added Mark's rewritten commit log and some whitespace] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent e9ad390 commit ea0d55a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/arm64/kernel/entry-common.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ static void noinstr el0_breakpt(struct pt_regs *regs, unsigned long esr)
697697

698698
static void noinstr el0_softstp(struct pt_regs *regs, unsigned long esr)
699699
{
700+
bool step_done;
701+
700702
if (!is_ttbr0_addr(regs->pc))
701703
arm64_apply_bp_hardening();
702704

@@ -707,10 +709,10 @@ static void noinstr el0_softstp(struct pt_regs *regs, unsigned long esr)
707709
* If we are stepping a suspended breakpoint there's nothing more to do:
708710
* the single-step is complete.
709711
*/
710-
if (!try_step_suspended_breakpoints(regs)) {
711-
local_daif_restore(DAIF_PROCCTX);
712+
step_done = try_step_suspended_breakpoints(regs);
713+
local_daif_restore(DAIF_PROCCTX);
714+
if (!step_done)
712715
do_el0_softstep(esr, regs);
713-
}
714716
arm64_exit_to_user_mode(regs);
715717
}
716718

0 commit comments

Comments
 (0)