aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-07-31 06:36:08 -0400
committerWill Deacon <will.deacon@arm.com>2014-07-31 06:36:08 -0400
commitc878e0cff5c5e56b216951cbe75f7a3dd500a736 (patch)
tree234fca64e4707b18b7c1bfe354348e9a096badbf
parent3666f88010d71e752ad677ec64edf148366afb7a (diff)
arm64: don't call break hooks for BRK exceptions from EL0
Our break hooks are used to handle brk exceptions from kgdb (and potentially kprobes if that code ever resurfaces), so don't bother calling them if the BRK exception comes from userspace. This prevents userspace from trapping to a kdb shell on systems where kgdb is enabled and active. Cc: <stable@vger.kernel.org> Reported-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/kernel/debug-monitors.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index a7fb874b595e..fe5b94078d82 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -315,20 +315,20 @@ static int brk_handler(unsigned long addr, unsigned int esr,
315{ 315{
316 siginfo_t info; 316 siginfo_t info;
317 317
318 if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED) 318 if (user_mode(regs)) {
319 return 0; 319 info = (siginfo_t) {
320 .si_signo = SIGTRAP,
321 .si_errno = 0,
322 .si_code = TRAP_BRKPT,
323 .si_addr = (void __user *)instruction_pointer(regs),
324 };
320 325
321 if (!user_mode(regs)) 326 force_sig_info(SIGTRAP, &info, current);
327 } else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
328 pr_warning("Unexpected kernel BRK exception at EL1\n");
322 return -EFAULT; 329 return -EFAULT;
330 }
323 331
324 info = (siginfo_t) {
325 .si_signo = SIGTRAP,
326 .si_errno = 0,
327 .si_code = TRAP_BRKPT,
328 .si_addr = (void __user *)instruction_pointer(regs),
329 };
330
331 force_sig_info(SIGTRAP, &info, current);
332 return 0; 332 return 0;
333} 333}
334 334