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

Commit c24cc8a9 authored by Josh Gao's avatar Josh Gao
Browse files

crash_dump: collect open files before dropping caps.

/proc/<pid>/fd is also limited by ptrace_may_access.

Test: manual inspection of "debuggerd -b `pidof zygote`"
Change-Id: I1a28c21c0438fe8729bd8e041c6b418d6a84c586
parent 7a0ee64f
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -363,6 +363,12 @@ int main(int argc, char** argv) {
    LOG(FATAL) << "failed to create backtrace map";
    LOG(FATAL) << "failed to create backtrace map";
  }
  }


  // Collect the list of open files.
  OpenFilesList open_files;
  if (!backtrace) {
    populate_open_files_list(target, &open_files);
  }

  // Drop our capabilities now that we've attached to the threads we care about.
  // Drop our capabilities now that we've attached to the threads we care about.
  drop_capabilities();
  drop_capabilities();


@@ -375,10 +381,6 @@ int main(int argc, char** argv) {
  if (backtrace) {
  if (backtrace) {
    dump_backtrace(output_fd.get(), backtrace_map.get(), target, main_tid, attached_siblings, 0);
    dump_backtrace(output_fd.get(), backtrace_map.get(), target, main_tid, attached_siblings, 0);
  } else {
  } else {
    // Collect the list of open files.
    OpenFilesList open_files;
    populate_open_files_list(target, &open_files);

    engrave_tombstone(output_fd.get(), backtrace_map.get(), open_files, target, main_tid,
    engrave_tombstone(output_fd.get(), backtrace_map.get(), open_files, target, main_tid,
                      attached_siblings, abort_address, fatal_signal ? &amfd_data : nullptr);
                      attached_siblings, abort_address, fatal_signal ? &amfd_data : nullptr);
  }
  }