Commit 53d07e21 authored by Pratyush Anand's avatar Pratyush Anand Committed by Catalin Marinas

arm64: Handle TRAP_BRKPT for user mode as well

uprobe is registered at break_hook with a unique ESR code. So, when a
TRAP_BRKPT occurs, call_break_hook checks if it was for uprobe. If not,
then send a SIGTRAP to user.
Signed-off-by: default avatarPratyush Anand <panand@redhat.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 3fb69640
...@@ -306,16 +306,20 @@ NOKPROBE_SYMBOL(call_break_hook); ...@@ -306,16 +306,20 @@ NOKPROBE_SYMBOL(call_break_hook);
static int brk_handler(unsigned long addr, unsigned int esr, static int brk_handler(unsigned long addr, unsigned int esr,
struct pt_regs *regs) struct pt_regs *regs)
{ {
if (user_mode(regs)) { bool handler_found = false;
send_user_sigtrap(TRAP_BRKPT);
}
#ifdef CONFIG_KPROBES #ifdef CONFIG_KPROBES
else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) { if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED) if (kprobe_breakpoint_handler(regs, esr) == DBG_HOOK_HANDLED)
return -EFAULT; handler_found = true;
} }
#endif #endif
else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) { if (!handler_found && call_break_hook(regs, esr) == DBG_HOOK_HANDLED)
handler_found = true;
if (!handler_found && user_mode(regs)) {
send_user_sigtrap(TRAP_BRKPT);
} else if (!handler_found) {
pr_warn("Unexpected kernel BRK exception at EL1\n"); pr_warn("Unexpected kernel BRK exception at EL1\n");
return -EFAULT; return -EFAULT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment