Skip to content

Commit

Permalink
arm64: kprobes: Restore local irqflag if kprobes is cancelled
Browse files Browse the repository at this point in the history
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 <Jisheng.Zhang@synaptics.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20210412174101.6bfb0594@xhacker.debian
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Jisheng Zhang authored and willdeacon committed Apr 13, 2021
1 parent 2decad9 commit 738fa58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/arm64/kernel/probes/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,12 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
if (!instruction_pointer(regs))
BUG();

if (kcb->kprobe_status == KPROBE_REENTER)
if (kcb->kprobe_status == KPROBE_REENTER) {
restore_previous_kprobe(kcb);
else
} else {
kprobes_restore_local_irqflag(kcb, regs);
reset_current_kprobe();
}

break;
case KPROBE_HIT_ACTIVE:
Expand Down

0 comments on commit 738fa58

Please sign in to comment.