diff options
author | Josh Gao <jmgao@google.com> | 2017-02-16 19:17:28 -0800 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-02-16 19:26:09 -0800 |
commit | 2a18b822d50f360b83e9ce3fd822d2650ed3a4db (patch) | |
tree | df1f9c23f7425a836ab8095859e89638d6be2321 /debuggerd | |
parent | 325eeebc47d9f8ac07c5e390f46c8f58a1621180 (diff) | |
download | core-2a18b822d50f360b83e9ce3fd822d2650ed3a4db.tar.gz core-2a18b822d50f360b83e9ce3fd822d2650ed3a4db.tar.bz2 core-2a18b822d50f360b83e9ce3fd822d2650ed3a4db.zip |
crash_dump: remove unneeded/faulty checks.
We already check our /proc/`getppid()` fd every time we attach a thread, so
these were unneeded at best. The one that happened after dropping
capabilities was actively wrong, though, because /proc/pid access
checks happen on every operation. (only on some kernels?)
Also, add a check that getppid() doesn't change after opening
/proc/getppid().
Bug: http://b/35241370
Test: debuggerd -b `pidof com.android.bluetooth`
Change-Id: I807439d8c2afd027f3c382face50167a8a7946c4
Diffstat (limited to 'debuggerd')
-rw-r--r-- | debuggerd/crash_dump.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index 08b0047be..0e154728a 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp @@ -219,17 +219,6 @@ static void drop_capabilities() { } } -static void check_process(int proc_fd, pid_t expected_pid) { - android::procinfo::ProcessInfo proc_info; - if (!android::procinfo::GetProcessInfoFromProcPidFd(proc_fd, &proc_info)) { - LOG(FATAL) << "failed to fetch process info"; - } - - if (proc_info.pid != expected_pid) { - LOG(FATAL) << "pid mismatch: expected " << expected_pid << ", actual " << proc_info.pid; - } -} - int main(int argc, char** argv) { pid_t target = getppid(); bool tombstoned_connected = false; @@ -282,6 +271,11 @@ int main(int argc, char** argv) { PLOG(FATAL) << "failed to open " << target_proc_path; } + // Make sure our parent didn't die. + if (getppid() != target) { + PLOG(FATAL) << "parent died"; + } + // Reparent ourselves to init, so that the signal handler can waitpid on the // original process to avoid leaving a zombie for non-fatal dumps. pid_t forkpid = fork(); @@ -294,8 +288,6 @@ int main(int argc, char** argv) { // Die if we take too long. alarm(20); - check_process(target_proc_fd, target); - std::string attach_error; // Seize the main thread. @@ -337,7 +329,6 @@ int main(int argc, char** argv) { // Drop our capabilities now that we've attached to the threads we care about. drop_capabilities(); - check_process(target_proc_fd, target); LOG(INFO) << "obtaining output fd from tombstoned"; tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd); |