d4aa14d9dd
For the perf profiling signal handler to succeed in opening /proc/self/mem, the process needs to be marked as dumpable in posix terms. This patch addresses a scenario since Android S where the process is considered profileable, but is not dumpable on "user" builds. The solution is to mark the process as dumpable while opening the procfs descriptors, restoring the original value afterwards. This is the same approach as the heapprofd heap profiler, which performs the override within the loaded client library [1]. The particular scenario being addressed is: * user build * app does not explicitly opt into being profiled by shell * app does not explicitly opt out of all profiling In this case, the app is considered profileable by the platform (but NOT shell). Therefore ActivityThread marks the process as profileable [2], but the zygote keeps the process as undumpable as it considers the profileability from the shell domain [3]. We could change the logic in the zygote to leave such processes in the dumpable state, but the override within the signal handler is considered to be more contained as the dumpability is only needed temporarily. This override would also apply for any non-dumpable native services that are signalled for profiling, which is also desireable for profiling coverage. This change does not elide any of the existing profileability checks by the signal handler's preamble and the profiler itself. [1] https://cs.android.com/android/platform/superproject/+/master:external/perfetto/src/profiling/memory/client.cc;l=184;drc=78cd82ba31233ce810618e07d349fd34efdb861d [2] https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/ActivityThread.java;l=6610;drc=de9cf3392d7872c2bee69b65a614e77bb166b26e [3] https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/jni/com_android_internal_os_Zygote.cpp;l=1680;drc=master Tested: clock app on barbet-user succeeds in opening the procfs descriptors within the signal handler. Tested: systemwide profiling on sargo-userdebug works as before. Bug: 196810669 BYPASS_INCLUSIVE_LANGUAGE_REASON=referencing the name of a cmdline utility Change-Id: Id621d4312418ff0736c97065e9ee577ff67f40da |
||
---|---|---|
.. | ||
arch-arm | ||
arch-arm64 | ||
arch-common/bionic | ||
arch-x86 | ||
arch-x86_64 | ||
async_safe | ||
b64/include/bionic | ||
bionic | ||
dns | ||
execinfo/include | ||
fts/include | ||
include | ||
kernel | ||
malloc_debug | ||
malloc_hooks | ||
platform | ||
private | ||
seccomp | ||
stdio | ||
system_properties | ||
tools | ||
tzcode | ||
upstream-freebsd | ||
upstream-netbsd | ||
upstream-openbsd | ||
versioner-dependencies | ||
Android.bp | ||
fs_config_generator.py | ||
libc.map.txt | ||
libstdc++.map.txt | ||
MODULE_LICENSE_BSD | ||
NOTICE | ||
SECCOMP_ALLOWLIST_APP.TXT | ||
SECCOMP_ALLOWLIST_COMMON.TXT | ||
SECCOMP_ALLOWLIST_SYSTEM.TXT | ||
SECCOMP_BLOCKLIST_APP.TXT | ||
SECCOMP_BLOCKLIST_COMMON.TXT | ||
SECCOMP_PRIORITY.TXT | ||
SYSCALLS.TXT | ||
version_script.txt |