summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Hector Chavez2017-12-27 14:36:02 -0600
committerLuis Hector Chavez2017-12-27 15:19:31 -0600
commit4841e744c2e148a68c0f592729d55fa41f39c112 (patch)
tree403ca0b71cbd5b62869384fd68bd7814a72fb2a6 /debuggerd
parent93d344d98cd02d66c3aac8067718be828ea283f9 (diff)
downloadplatform-system-core-4841e744c2e148a68c0f592729d55fa41f39c112.tar.gz
platform-system-core-4841e744c2e148a68c0f592729d55fa41f39c112.tar.xz
platform-system-core-4841e744c2e148a68c0f592729d55fa41f39c112.zip
debuggerd_handler: set PR_SET_PTRACER before running crash_dump.
Set and restore PR_SET_PTRACER when performing a dump, so that when Android is running on a kernel that has the Yama LSM enabled (and the value of ptrace_scope is > 0), crash_dump can attach to processes and print nice, symbolized stack traces. Bug: 70992745 Test: kill -6 `pidof surfaceflinger` && logcat -d -b crash # in both sailfish and Chrome OS Change-Id: If4646442c6000fdcc69cf4ab95fdc71ae74baaaf
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/handler/debuggerd_handler.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index 96f3c7c54..05e6efa60 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -500,6 +500,17 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
500 fatal_errno("failed to set dumpable"); 500 fatal_errno("failed to set dumpable");
501 } 501 }
502 502
503 // On kernels with yama_ptrace enabled, also allow any process to attach.
504 bool restore_orig_ptracer = true;
505 if (prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY) != 0) {
506 if (errno == EINVAL) {
507 // This kernel does not support PR_SET_PTRACER_ANY, or Yama is not enabled.
508 restore_orig_ptracer = false;
509 } else {
510 fatal_errno("failed to set traceable");
511 }
512 }
513
503 // Essentially pthread_create without CLONE_FILES, so we still work during file descriptor 514 // Essentially pthread_create without CLONE_FILES, so we still work during file descriptor
504 // exhaustion. 515 // exhaustion.
505 pid_t child_pid = 516 pid_t child_pid =
@@ -521,6 +532,11 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
521 fatal_errno("failed to restore dumpable"); 532 fatal_errno("failed to restore dumpable");
522 } 533 }
523 534
535 // Restore PR_SET_PTRACER to its original value.
536 if (restore_orig_ptracer && prctl(PR_SET_PTRACER, 0) != 0) {
537 fatal_errno("failed to restore traceable");
538 }
539
524 if (info->si_signo == DEBUGGER_SIGNAL) { 540 if (info->si_signo == DEBUGGER_SIGNAL) {
525 // If the signal is fatal, don't unlock the mutex to prevent other crashing threads from 541 // If the signal is fatal, don't unlock the mutex to prevent other crashing threads from
526 // starting to dump right before our death. 542 // starting to dump right before our death.