summaryrefslogtreecommitdiff
path: root/debuggerd/handler/debuggerd_handler.cpp
diff options
context:
space:
mode:
authorBruce Levy <blevy@codeaurora.org>2018-01-17 22:19:21 -0800
committerBruce Levy <blevy@codeaurora.org>2018-01-18 13:55:48 -0800
commita1976de9450b21810196ee7937341491e7167446 (patch)
tree882adbc9076fd55fdda5957f4c402fda40037c29 /debuggerd/handler/debuggerd_handler.cpp
parent58127ac219f757973f2fa277699e1c2ed83dec85 (diff)
parent3926655cda1c63b97fd35c7d6f337504c1ec2741 (diff)
P PPR1.180114.001 merge 3926655cda1c63b97fd35c7d6f337504c1ec2741 - clean
Change-Id: I72d227485017ef4a6003997524628c4c78be521d
Diffstat (limited to 'debuggerd/handler/debuggerd_handler.cpp')
-rw-r--r--debuggerd/handler/debuggerd_handler.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index 5d9cffb38..5a94d3dcf 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -498,7 +498,18 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
if (prctl(PR_SET_DUMPABLE, 1) != 0) {
fatal_errno("failed to set dumpable");
}
-
+
+ // On kernels with yama_ptrace enabled, also allow any process to attach.
+ bool restore_orig_ptracer = true;
+ if (prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY) != 0) {
+ if (errno == EINVAL) {
+ // This kernel does not support PR_SET_PTRACER_ANY, or Yama is not enabled.
+ restore_orig_ptracer = false;
+ } else {
+ fatal_errno("failed to set traceable");
+ }
+ }
+
// Essentially pthread_create without CLONE_FILES, so we still work during file descriptor
// exhaustion.
pid_t child_pid =
@@ -525,6 +536,11 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
signal(signal_number, SIG_DFL);
}
+ // Restore PR_SET_PTRACER to its original value.
+ if (restore_orig_ptracer && prctl(PR_SET_PTRACER, 0) != 0) {
+ fatal_errno("failed to restore traceable");
+ }
+
if (info->si_signo == DEBUGGER_SIGNAL) {
// If the signal is fatal, don't unlock the mutex to prevent other crashing threads from
// starting to dump right before our death.