Loading cmds/dumpstate/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,7 @@ cc_defaults { "libdumpstateaidl", "libdumpstateaidl", "libdumpstateutil", "libdumpstateutil", "libdumputils", "libdumputils", "libhardware_legacy", "libhidlbase", "libhidlbase", "libhidltransport", "libhidltransport", "liblog", "liblog", Loading cmds/dumpstate/DumpstateInternal.cpp +7 −1 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,8 @@ bool DropRootUser() { } } static const std::vector<std::string> group_names{ static const std::vector<std::string> group_names{ "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats", "readproc", "bluetooth"}; "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats", "readproc", "bluetooth", "wakelock"}; std::vector<gid_t> groups(group_names.size(), 0); std::vector<gid_t> groups(group_names.size(), 0); for (size_t i = 0; i < group_names.size(); ++i) { for (size_t i = 0; i < group_names.size(); ++i) { grp = getgrnam(group_names[i].c_str()); grp = getgrnam(group_names[i].c_str()); Loading Loading @@ -116,6 +117,11 @@ bool DropRootUser() { capdata[cap_syslog_index].effective |= cap_syslog_mask; capdata[cap_syslog_index].effective |= cap_syslog_mask; } } const uint32_t cap_block_suspend_mask = CAP_TO_MASK(CAP_BLOCK_SUSPEND); const uint32_t cap_block_suspend_index = CAP_TO_INDEX(CAP_BLOCK_SUSPEND); capdata[cap_block_suspend_index].permitted |= cap_block_suspend_mask; capdata[cap_block_suspend_index].effective |= cap_block_suspend_mask; if (capset(&capheader, &capdata[0]) != 0) { if (capset(&capheader, &capdata[0]) != 0) { MYLOGE("capset({%#x, %#x}) failed: %s\n", capdata[0].effective, MYLOGE("capset({%#x, %#x}) failed: %s\n", capdata[0].effective, capdata[1].effective, strerror(errno)); capdata[1].effective, strerror(errno)); Loading cmds/dumpstate/dumpstate.cpp +10 −0 Original line number Original line Diff line number Diff line Loading @@ -71,6 +71,7 @@ #include <debuggerd/client.h> #include <debuggerd/client.h> #include <dumpsys.h> #include <dumpsys.h> #include <dumputils/dump_utils.h> #include <dumputils/dump_utils.h> #include <hardware_legacy/power.h> #include <hidl/ServiceManagement.h> #include <hidl/ServiceManagement.h> #include <log/log.h> #include <log/log.h> #include <openssl/sha.h> #include <openssl/sha.h> Loading Loading @@ -177,6 +178,8 @@ static const std::string ANR_FILE_PREFIX = "anr_"; func_ptr(__VA_ARGS__); \ func_ptr(__VA_ARGS__); \ RETURN_IF_USER_DENIED_CONSENT(); RETURN_IF_USER_DENIED_CONSENT(); static const char* WAKE_LOCK_NAME = "dumpstate_wakelock"; namespace android { namespace android { namespace os { namespace os { namespace { namespace { Loading Loading @@ -2468,6 +2471,13 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, MYLOGI("begin\n"); MYLOGI("begin\n"); if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) { MYLOGE("Failed to acquire wake lock: %s\n", strerror(errno)); } else { // Wake lock will be released automatically on process death MYLOGD("Wake lock acquired.\n"); } register_sig_handler(); register_sig_handler(); // TODO(b/111441001): maybe skip if already started? // TODO(b/111441001): maybe skip if already started? Loading Loading
cmds/dumpstate/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,7 @@ cc_defaults { "libdumpstateaidl", "libdumpstateaidl", "libdumpstateutil", "libdumpstateutil", "libdumputils", "libdumputils", "libhardware_legacy", "libhidlbase", "libhidlbase", "libhidltransport", "libhidltransport", "liblog", "liblog", Loading
cmds/dumpstate/DumpstateInternal.cpp +7 −1 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,8 @@ bool DropRootUser() { } } static const std::vector<std::string> group_names{ static const std::vector<std::string> group_names{ "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats", "readproc", "bluetooth"}; "log", "sdcard_r", "sdcard_rw", "mount", "inet", "net_bw_stats", "readproc", "bluetooth", "wakelock"}; std::vector<gid_t> groups(group_names.size(), 0); std::vector<gid_t> groups(group_names.size(), 0); for (size_t i = 0; i < group_names.size(); ++i) { for (size_t i = 0; i < group_names.size(); ++i) { grp = getgrnam(group_names[i].c_str()); grp = getgrnam(group_names[i].c_str()); Loading Loading @@ -116,6 +117,11 @@ bool DropRootUser() { capdata[cap_syslog_index].effective |= cap_syslog_mask; capdata[cap_syslog_index].effective |= cap_syslog_mask; } } const uint32_t cap_block_suspend_mask = CAP_TO_MASK(CAP_BLOCK_SUSPEND); const uint32_t cap_block_suspend_index = CAP_TO_INDEX(CAP_BLOCK_SUSPEND); capdata[cap_block_suspend_index].permitted |= cap_block_suspend_mask; capdata[cap_block_suspend_index].effective |= cap_block_suspend_mask; if (capset(&capheader, &capdata[0]) != 0) { if (capset(&capheader, &capdata[0]) != 0) { MYLOGE("capset({%#x, %#x}) failed: %s\n", capdata[0].effective, MYLOGE("capset({%#x, %#x}) failed: %s\n", capdata[0].effective, capdata[1].effective, strerror(errno)); capdata[1].effective, strerror(errno)); Loading
cmds/dumpstate/dumpstate.cpp +10 −0 Original line number Original line Diff line number Diff line Loading @@ -71,6 +71,7 @@ #include <debuggerd/client.h> #include <debuggerd/client.h> #include <dumpsys.h> #include <dumpsys.h> #include <dumputils/dump_utils.h> #include <dumputils/dump_utils.h> #include <hardware_legacy/power.h> #include <hidl/ServiceManagement.h> #include <hidl/ServiceManagement.h> #include <log/log.h> #include <log/log.h> #include <openssl/sha.h> #include <openssl/sha.h> Loading Loading @@ -177,6 +178,8 @@ static const std::string ANR_FILE_PREFIX = "anr_"; func_ptr(__VA_ARGS__); \ func_ptr(__VA_ARGS__); \ RETURN_IF_USER_DENIED_CONSENT(); RETURN_IF_USER_DENIED_CONSENT(); static const char* WAKE_LOCK_NAME = "dumpstate_wakelock"; namespace android { namespace android { namespace os { namespace os { namespace { namespace { Loading Loading @@ -2468,6 +2471,13 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, MYLOGI("begin\n"); MYLOGI("begin\n"); if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) { MYLOGE("Failed to acquire wake lock: %s\n", strerror(errno)); } else { // Wake lock will be released automatically on process death MYLOGD("Wake lock acquired.\n"); } register_sig_handler(); register_sig_handler(); // TODO(b/111441001): maybe skip if already started? // TODO(b/111441001): maybe skip if already started? Loading