diff options
author | Will Deacon <will.deacon@arm.com> | 2014-07-31 11:36:08 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-12-04 20:57:01 +0000 |
commit | f2b7e24db711980fe702d572ffd93ba179824a54 (patch) | |
tree | f9295156bfab0c0a199ba579e784b5f72b82037f | |
parent | f1b16430b5cda0aaf53a66f914f48e86f13f590c (diff) |
arm64: don't call break hooks for BRK exceptions from EL0v3.14/topic/arm64-kgdb
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>
(cherry picked from commit c878e0cff5c5e56b216951cbe75f7a3dd500a736)
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | arch/arm64/kernel/debug-monitors.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index bb9a0e684e12..fbab2e21c87d 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -312,20 +312,20 @@ static int brk_handler(unsigned long addr, unsigned int esr, { siginfo_t info; - if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED) - return 0; + if (user_mode(regs)) { + info = (siginfo_t) { + .si_signo = SIGTRAP, + .si_errno = 0, + .si_code = TRAP_BRKPT, + .si_addr = (void __user *)instruction_pointer(regs), + }; - if (!user_mode(regs)) + force_sig_info(SIGTRAP, &info, current); + } else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) { + pr_warning("Unexpected kernel BRK exception at EL1\n"); return -EFAULT; + } - info = (siginfo_t) { - .si_signo = SIGTRAP, - .si_errno = 0, - .si_code = TRAP_BRKPT, - .si_addr = (void __user *)instruction_pointer(regs), - }; - - force_sig_info(SIGTRAP, &info, current); return 0; } |