Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1491727
| From | Pratyush Anand <panand@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH V2 4/6] arm64: Handle TRAP_BRKPT for user mode as well |
| Date | 2016-09-27 09:50 +0200 |
| Message-ID | <slVjk-6IZ-25@gated-at.bofh.it> (permalink) |
| References | <slVjj-6IZ-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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: Pratyush Anand <panand@redhat.com>
---
arch/arm64/kernel/debug-monitors.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index a8f8de012250..605df76f0a06 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -306,16 +306,20 @@ NOKPROBE_SYMBOL(call_break_hook);
static int brk_handler(unsigned long addr, unsigned int esr,
struct pt_regs *regs)
{
- if (user_mode(regs)) {
- send_user_sigtrap(TRAP_BRKPT);
- }
+ bool handler_found = false;
+
#ifdef CONFIG_KPROBES
- else if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
- if (kprobe_breakpoint_handler(regs, esr) != DBG_HOOK_HANDLED)
- return -EFAULT;
+ if ((esr & BRK64_ESR_MASK) == BRK64_ESR_KPROBES) {
+ if (kprobe_breakpoint_handler(regs, esr) == DBG_HOOK_HANDLED)
+ handler_found = true;
}
#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");
return -EFAULT;
}
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V2 0/6] ARM64: Uprobe support added Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200 [PATCH V2 4/6] arm64: Handle TRAP_BRKPT for user mode as well Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200 [PATCH V2 1/6] arm64: kprobe: protect/rename few definitions to be reused by uprobe Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200 [PATCH V2 3/6] arm64: Handle TRAP_TRACE for user mode as well Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200 [PATCH V2 5/6] arm64: introduce mm context flag to keep 32 bit task information Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200 [PATCH V2 2/6] arm64: kgdb_step_brk_fn: ignore other's exception Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200 [PATCH V2 6/6] arm64: Add uprobe support Pratyush Anand <panand@redhat.com> - 2016-09-27 09:50 +0200
csiph-web