Skip to content

Commit 738fa58

Browse files
rvoskwilldeacon
authored andcommitted
arm64: kprobes: Restore local irqflag if kprobes is cancelled
If instruction being single stepped caused a page fault, the kprobes is cancelled to let the page fault handler continue as a normal page fault. But the local irqflags are disabled so cpu will restore pstate with DAIF masked. After pagefault is serviced, the kprobes is triggerred again, we overwrite the saved_irqflag by calling kprobes_save_local_irqflag(). NOTE, DAIF is masked in this new saved irqflag. After kprobes is serviced, the cpu pstate is retored with DAIF masked. This patch is inspired by one patch for riscv from Liao Chang. Signed-off-by: Jisheng Zhang <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 2decad9 commit 738fa58

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/arm64/kernel/probes/kprobes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,12 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
267267
if (!instruction_pointer(regs))
268268
BUG();
269269

270-
if (kcb->kprobe_status == KPROBE_REENTER)
270+
if (kcb->kprobe_status == KPROBE_REENTER) {
271271
restore_previous_kprobe(kcb);
272-
else
272+
} else {
273+
kprobes_restore_local_irqflag(kcb, regs);
273274
reset_current_kprobe();
275+
}
274276

275277
break;
276278
case KPROBE_HIT_ACTIVE:

0 commit comments

Comments
 (0)