Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df53f4d0 authored by Luis Hector Chavez's avatar Luis Hector Chavez Committed by android-build-merger
Browse files

Merge "debuggerd_handler: set PR_SET_PTRACER before running crash_dump." am:...

Merge "debuggerd_handler: set PR_SET_PTRACER before running crash_dump." am: be10cae4 am: 66fa613d
am: 8b4cbf4a

Change-Id: I5a6f242e96681be678a337d802b178ef92231dba
parents 74c050b0 8b4cbf4a
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -500,6 +500,17 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
    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 =
@@ -521,6 +532,11 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* c
    fatal_errno("failed to restore dumpable");
  }

  // 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.