Loading debuggerd/crash_dump.cpp +5 −14 Original line number Original line Diff line number Diff line Loading @@ -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) { int main(int argc, char** argv) { pid_t target = getppid(); pid_t target = getppid(); bool tombstoned_connected = false; bool tombstoned_connected = false; Loading Loading @@ -282,6 +271,11 @@ int main(int argc, char** argv) { PLOG(FATAL) << "failed to open " << target_proc_path; 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 // Reparent ourselves to init, so that the signal handler can waitpid on the // original process to avoid leaving a zombie for non-fatal dumps. // original process to avoid leaving a zombie for non-fatal dumps. pid_t forkpid = fork(); pid_t forkpid = fork(); Loading @@ -294,8 +288,6 @@ int main(int argc, char** argv) { // Die if we take too long. // Die if we take too long. alarm(20); alarm(20); check_process(target_proc_fd, target); std::string attach_error; std::string attach_error; // Seize the main thread. // Seize the main thread. Loading Loading @@ -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 our capabilities now that we've attached to the threads we care about. drop_capabilities(); drop_capabilities(); check_process(target_proc_fd, target); LOG(INFO) << "obtaining output fd from tombstoned"; LOG(INFO) << "obtaining output fd from tombstoned"; tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd); tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd); Loading debuggerd/handler/debuggerd_handler.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -202,7 +202,7 @@ static void raise_caps() { uint64_t capmask = capdata[0].inheritable; uint64_t capmask = capdata[0].inheritable; capmask |= static_cast<uint64_t>(capdata[1].inheritable) << 32; capmask |= static_cast<uint64_t>(capdata[1].inheritable) << 32; for (unsigned long i = 0; i < 64; ++i) { for (unsigned long i = 0; i < 64; ++i) { if (capmask & (1 << i)) { if (capmask & (1ULL << i)) { if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, i, 0, 0) != 0) { if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, i, 0, 0) != 0) { __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to raise ambient capability %lu: %s", __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to raise ambient capability %lu: %s", i, strerror(errno)); i, strerror(errno)); Loading Loading
debuggerd/crash_dump.cpp +5 −14 Original line number Original line Diff line number Diff line Loading @@ -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) { int main(int argc, char** argv) { pid_t target = getppid(); pid_t target = getppid(); bool tombstoned_connected = false; bool tombstoned_connected = false; Loading Loading @@ -282,6 +271,11 @@ int main(int argc, char** argv) { PLOG(FATAL) << "failed to open " << target_proc_path; 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 // Reparent ourselves to init, so that the signal handler can waitpid on the // original process to avoid leaving a zombie for non-fatal dumps. // original process to avoid leaving a zombie for non-fatal dumps. pid_t forkpid = fork(); pid_t forkpid = fork(); Loading @@ -294,8 +288,6 @@ int main(int argc, char** argv) { // Die if we take too long. // Die if we take too long. alarm(20); alarm(20); check_process(target_proc_fd, target); std::string attach_error; std::string attach_error; // Seize the main thread. // Seize the main thread. Loading Loading @@ -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 our capabilities now that we've attached to the threads we care about. drop_capabilities(); drop_capabilities(); check_process(target_proc_fd, target); LOG(INFO) << "obtaining output fd from tombstoned"; LOG(INFO) << "obtaining output fd from tombstoned"; tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd); tombstoned_connected = tombstoned_connect(target, &tombstoned_socket, &output_fd); Loading
debuggerd/handler/debuggerd_handler.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -202,7 +202,7 @@ static void raise_caps() { uint64_t capmask = capdata[0].inheritable; uint64_t capmask = capdata[0].inheritable; capmask |= static_cast<uint64_t>(capdata[1].inheritable) << 32; capmask |= static_cast<uint64_t>(capdata[1].inheritable) << 32; for (unsigned long i = 0; i < 64; ++i) { for (unsigned long i = 0; i < 64; ++i) { if (capmask & (1 << i)) { if (capmask & (1ULL << i)) { if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, i, 0, 0) != 0) { if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, i, 0, 0) != 0) { __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to raise ambient capability %lu: %s", __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to raise ambient capability %lu: %s", i, strerror(errno)); i, strerror(errno)); Loading