Re: [PATCH] arm64: kprobes: Fix Uexpected kernel BRK exception at EL1

From: Will Deacon
Date: Fri Jan 22 2021 - 12:31:44 EST


On Fri, Jan 22, 2021 at 11:09:09AM +0000, Qais Yousef wrote:
> I was hitting the below panic continuously when attaching kprobes to
> scheduler functions

[...]

> diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
> index 89c64ada8732..66aac2881ba8 100644
> --- a/arch/arm64/kernel/probes/kprobes.c
> +++ b/arch/arm64/kernel/probes/kprobes.c
> @@ -352,8 +352,8 @@ kprobe_breakpoint_ss_handler(struct pt_regs *regs, unsigned int esr)
> unsigned long addr = instruction_pointer(regs);
> struct kprobe *cur = kprobe_running();
>
> - if (cur && (kcb->kprobe_status == KPROBE_HIT_SS)
> - && ((unsigned long)&cur->ainsn.api.insn[1] == addr)) {
> + if (cur && (kcb->kprobe_status & (KPROBE_HIT_SS | KPROBE_REENTER)) &&
> + ((unsigned long)&cur->ainsn.api.insn[1] == addr)) {
> kprobes_restore_local_irqflag(kcb, regs);
> post_kprobe_handler(cur, kcb, regs);

Acked-by: Will Deacon <will@xxxxxxxxxx>

Catalin can pick this up for 5.11.

Will